-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macOS port of the upgrade-assistant (#1409)
* Use a hard-coded PackageId for Extensions.Default.Analyzers Don't use $(MSBuildProjectFullPath)* because it includes the full path and breaks NuGet caching logic on non-Windows platforms. * Do not require the ENABLE_CROSS_PLATFORM feature flag to run on macOS * Don't crash in VisualStudioFinder.Configure() due to COM exceptions * Use sudo on macOS when running `dotnet workload install maui` * Trim trailing whitespace (CRLF) from the using directive when searching for it in the template This is an actual code-change fix that helps unit tests pass * A bunch of fixes to the unit tests Most of these fixes fit into the following categories: 1. File path construction (using the correct path separator for the platform) 2. Using .ReplaceLineEndings() on strings that represent file content so we get consistent line endings when comparing expected/actual results 3. Adding TextSpan file offsets to use on Unix platforms (e.g. macOS) which will be different from the TextSpans on Windows * Fixed MappedSubTextTests (and found a legit bug in MappedSubText regarding line ending assumptions) * Fixed RazorHelperUpdaterTests File paths needed to be sorted. The returned order is different on macOS than on Windows for some reason. * Fixed RazorMappedTextReplacerTests and RazorSourceUpdaterTests Use .ReplaceLineEndings() on source strings * Fixed WCFUpdaterTests * Fixed pruning of duplicate Compile/None items on macOS Needed to canonicalize the EvaluatedInclude paths before comparing them. * More path directory separator fixes * Need to compare item.Include/EvaluatedInclude using canonical paths * Moved GetProjectName() call out of the inner loop * More canonicalization of paths when used in comparisons * More canonicalization of paths * Fixed up paths in <ItemType Update=...> and <ItemType Remove=...> * Needed to add more .ReplaceLineEndings() in the unit tests for Razor * Only use the VisualStudioPath/Version on the Windows platform * Create a temp MSBuildExtensionsPath on macOS The upgrade-assistant uses dotnet's MSBuild while older Xamarin.iOS/Mac/Android/etc projects used Mono's XBuild (an MSBuild clone). Unfortunately, there's no way to specify that dotnet's MSBuild should look in both /usr/local/share/dotnet/sdk/{version} directory *and* in the /Library/Frameworks/Mono.framework/External/xbuild directories for the $(MSBuildExtensionsPath) imports. In order to be able to load Xamarin.* projects, we need to create a temp dir that includes *both* the standard targets/props files *and* the Xamarin props/targets files and the only way to do that seems to be to create a temp directory full of symlinks. * Optimized ProjectRootElementExtensionsForConversion.GetProjectName() Instead of using projectPath.Split('/').Last() and then result.Substring(), just get the start/end indexes of the substring we want and only do 1 Substring() operation. * Add a start-up warning for MacOS * Use "dotnet-upgrade-assistant" in the temp directory path * Use a predictable ~/.dotnet-upgrade-assistant/dotnet-sdk/{version} directory * Use !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) when deciding whether or not to use sudo dotnet commands * Disable the PCL test on non-Windows * Disable some DependencyInjections Options tests on non-Windows platforms * Disable WinUI and WPF migrations on non-Windows platforms. These probably don't make sense to try to migrate on macOS. * Disable Razor UpgradeSteps on non-Windows platforms * Disable VisualBasic and WCF UpgradeSteps on non-Windows platforms * Updated warning message for MacOS * Reduce code duplication in conversion between file path separators * Don't swallow exceptions thrown while creating MSBuildExtensionsPath symlinks Surface these exceptions to the user. * Removed FIXME that is no longer necessary * File.Exists() returns false for symlinks to directories Use a different approach to avoid exceptions trying to create a symlink that already exists.
- Loading branch information
Showing
40 changed files
with
775 additions
and
305 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/cli/Microsoft.DotNet.UpgradeAssistant.Cli/LocalizedStrings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/common/Microsoft.DotNet.UpgradeAssistant.Abstractions/PathHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
|
||
namespace Microsoft.DotNet.UpgradeAssistant | ||
{ | ||
public static class PathHelpers | ||
{ | ||
public static string GetNativePath(string path) | ||
{ | ||
if (Path.DirectorySeparatorChar == '/') | ||
{ | ||
return path.Replace('\\', '/'); | ||
} | ||
|
||
return path; | ||
} | ||
|
||
public static string GetIncludePath(string path) | ||
{ | ||
if (Path.DirectorySeparatorChar == '/') | ||
{ | ||
return path.Replace('/', '\\'); | ||
} | ||
|
||
return path; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.