upgrade-assistant: Xamarin Android and Xamarin iOS CLI tool cannot find .CSharp.targets file
- Include the log file
upgrade-assistant.clef
that is produced in the working directory
I could not find a file upgrade-assistant.clef
.
Describe the bug
When trying to run the CLI tool on any iOS or Android project, I get an error that the .CSharp.targets
file cannot be found.
Exceptions (if any)
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/local/share/dotnet/sdk/7.0.202/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Confirm that the expression in the Import declaration "/usr/local/share/dotnet/sdk/7.0.202/Xamarin/iOS/Xamarin.iOS.CSharp.targets" is correct, and that the file exists on disk.
Full stack trace:
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/local/share/dotnet/sdk/7.0.202/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Confirm that the expression in the Import declaration
"/usr/local/share/dotnet/sdk/7.0.202/Xamarin/iOS/Xamarin.iOS.CSharp.targets" is correct, and that the file exists on disk. /Users/obbbrown/Documents/Repos/MobileAppsGit/Apps/TotalPlatformCommon.iOS/TotalPlatformCommon.iOS.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1,T2](IElementLocation elementLocation, String resourceName, T1 arg0, T2 arg1)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1&
imports)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, Project project, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService
loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId,
EvaluationContext evaluationContext, Boolean interactive)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext
evaluationContext, IDirectoryCacheFactory directoryCacheFactory)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
at Microsoft.UpgradeAssistant.Services.DefaultMsbuildProjectAccess..ctor(String projectPath, ILogger logger, CancellationToken cancellationToken)
at Microsoft.UpgradeAssistant.Cli.Slices.Services.Msbuild.MsbuildService.GetProjectAccessAsync(String projectPath, Boolean isReadOnly, ILogger logger, CancellationToken cancellationToken)
at Microsoft.UpgradeAssistant.Cli.Slices.Services.Project.MsbuildProjectBuilder.BuildAsync(ISolution solution, String projectPath, CancellationToken cancellationToken)
at Microsoft.UpgradeAssistant.Cli.Slices.Services.Project.ProjectService.GetProjectAsync(ISolution solution, String projectPath, CancellationToken cancellationToken)
at Microsoft.UpgradeAssistant.Cli.Slices.Services.Project.ProjectService.GetProjectByPathAsync(ISolution solution, String projectPath, ILogger logger, CancellationToken cancellationToken)
at UpgradeHost.GetTraitsAsync(String projectPath, CancellationToken cancellationToken)
at Spectre.Console.Flow.FlowContextExtensions.GetOriginalTraitsAsync(IFlowContext context, String projectPath, IUpgradeHost host, CancellationToken cancellationToken)
at Microsoft.UpgradeAssistant.Cli.Flow.Steps.Upgrade.SelectControllerFlowStep.<>c__DisplayClass8_0.<<ValidateUserInputAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Spectre.Console.Status.<>c__DisplayClass17_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Status/Status.cs:line 120
--- End of stack trace from previous location ---
at Spectre.Console.Progress.<>c__DisplayClass28_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 133
--- End of stack trace from previous location ---
at Spectre.Console.Internal.DefaultExclusivityMode.RunAsync[T](Func`1 func) in /_/src/Spectre.Console/Internal/DefaultExclusivityMode.cs:line 40
at Spectre.Console.Progress.StartAsync[T](Func`2 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 116
at Spectre.Console.Status.StartAsync[T](String status, Func`2 func) in /_/src/Spectre.Console/Live/Status/Status.cs:line 117
at Microsoft.UpgradeAssistant.Cli.Flow.Steps.Upgrade.SelectControllerFlowStep.ValidateUserInputAsync(IFlowContext context, CancellationToken cancellationToken)
at Spectre.Console.Flow.FlowRunner.RunAsync(CancellationToken cancellationToken)
Further technical details
- macOS 12.6
- Visual Studio for Mac 17.5.3
- dotnet 7.0.202
- CLI upgrade-assistant 0.5.30
- Xamarin.Android 13.2.0.0
- Xamarin.iOS 16.2.0.5
dotnet --list-sdks
2.1.816 [/usr/local/share/dotnet/sdk]
3.1.409 [/usr/local/share/dotnet/sdk]
3.1.410 [/usr/local/share/dotnet/sdk]
3.1.412 [/usr/local/share/dotnet/sdk]
3.1.413 [/usr/local/share/dotnet/sdk]
3.1.414 [/usr/local/share/dotnet/sdk]
3.1.415 [/usr/local/share/dotnet/sdk]
3.1.417 [/usr/local/share/dotnet/sdk]
3.1.420 [/usr/local/share/dotnet/sdk]
3.1.423 [/usr/local/share/dotnet/sdk]
3.1.424 [/usr/local/share/dotnet/sdk]
3.1.425 [/usr/local/share/dotnet/sdk]
3.1.426 [/usr/local/share/dotnet/sdk]
5.0.203 [/usr/local/share/dotnet/sdk]
5.0.301 [/usr/local/share/dotnet/sdk]
5.0.400 [/usr/local/share/dotnet/sdk]
5.0.401 [/usr/local/share/dotnet/sdk]
5.0.402 [/usr/local/share/dotnet/sdk]
5.0.403 [/usr/local/share/dotnet/sdk]
5.0.406 [/usr/local/share/dotnet/sdk]
5.0.408 [/usr/local/share/dotnet/sdk]
6.0.401 [/usr/local/share/dotnet/sdk]
6.0.402 [/usr/local/share/dotnet/sdk]
6.0.403 [/usr/local/share/dotnet/sdk]
6.0.404 [/usr/local/share/dotnet/sdk]
6.0.405 [/usr/local/share/dotnet/sdk]
6.0.406 [/usr/local/share/dotnet/sdk]
6.0.407 [/usr/local/share/dotnet/sdk]
7.0.100 [/usr/local/share/dotnet/sdk]
7.0.101 [/usr/local/share/dotnet/sdk]
7.0.102 [/usr/local/share/dotnet/sdk]
7.0.200 [/usr/local/share/dotnet/sdk]
7.0.202 [/usr/local/share/dotnet/sdk]
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (5 by maintainers)
@EeKay,
Weird, you got further than I’ve gotten. The symlink hack that I had suggested in an earlier comment got the build to be able to find the
Xamarin.[Android,iOS].CSharp.targets
files, but then it couldn’t locate the Xamarin.iOS v1.0 or MonoANdroid v11.0 frameworks, so I had to modify my*.csproj
files by adding<TargetFrameworkRootPath>/Library/Frameworks/Mono.framwework/External/xbuild-frameworks</TargetFrameworkRootPath>
. Once I did that, I was able to build.I’ve got a local patch that fixes the upgrade-assistant to create the proper symlinks for users (I did this in the 0.4.x version of the upgrade-assistant but when the logic got copied over to the 0.5 version, something broke and needed some tweaking), but I’ve been struggling to get the
TargetFrameworkRootPath
hack to work when loading projects in the upgrade-assistant.So that’s where I’m at right now…
Looks like the new upgrade assistant code-base (which is not located in this repo) is going to take a while to port to macOS. It’s not going to be as trivial as I had hoped (i.e. just fixing things to be able to locate the Xamarin.iOS/Android/etc targets files).
I would recommend trying to use the tool from Windows for the time being until I can figure out how to port the new code-base to macOS.