$SolutionDir incorrectly maps to $ProjectDir when deploying to iOS (simulator)
See original GitHub issueDescription
I have a CommonSettings.targets file in the solution folder: C:\dev\vs2022\MauiApp\
The project folder is: C:\dev\vs2022\MauiApp\MauiApp\
All builds fine but when deploying to iOS simulator fails with the below error that shows it’s looking in the wrong folder for the CommonSettings.targets file.
Adding this to the project file…:
<Import Project="$(SolutionDir)CommonSettings.targets" />
<Target Name="TestMessage" AfterTargets="Build">
<Message Text="========== SolutionDir is $(SolutionDir) ==========" Importance="high" />
<Message Text="========== ProjectDir is $(ProjectDir) ==========" Importance="high" />
</Target>
… yields this output:
1>========== SolutionDir is C:\dev\vs2022\MauiApp\ ==========
1>========== ProjectDir is C:\dev\vs2022\MauiApp\MauiApp\ ==========
Steps to Reproduce
- Clone https://github.com/mattleibow/maui-bug-repros/tree/repro-maui-7534
- Run on an iOS simulator via the build agent
- Observe the build succeeds but the deploy fails (but says it is fine)
Version with bug
6.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
any
Did you find any workaround?
Duplicating file in $ProjectDir or changing import and moving file to $ProjectDir works, but shouldn’t have to.
Relevant log output
There was an unhandled exception trying to deploy and run your application.
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project **"C:\dev\vs2022\MauiApp\MauiApp\CommonSettings.targets"** was not found. Confirm that the expression in the Import declaration "CommonSettings.targets" is correct, and that the file exists on disk. C:\dev\vs2022\MauiApp\MauiApp\MauiApp.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
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, Boolean throwOnFileNotExistsError)
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.ReevaluateIfNecessary(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 Xamarin.VisualStudio.IOS.AssetCatalog.AssetCatalogManager.CreateBuildProject() in D:\a\_work\1\s\src\Core\VisualStudio.IOS.AssetCatalog\AssetCatalogManager.cs:line 587
at Xamarin.VisualStudio.IOS.AssetCatalog.AssetCatalogManager.HasOnDemandResources() in D:\a\_work\1\s\src\Core\VisualStudio.IOS.AssetCatalog\AssetCatalogManager.cs:line 252
at Xamarin.VisualStudio.IOS.MonoTouchRunSessionInfo.<InitializeInstanceAsync>d__5.MoveNext() in D:\a\_work\1\s\src\Core\VisualStudio.IOS\Debugging\MonoTouchRunSessionInfo.cs:line 66
VS bug #1754390
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
[SOLVED] iOS simulators not showing up
Hello everyone! This problem first appeared when I updated Xcode 6.1 to version 6.2. At that point, the system let me keep 6.1...
Read more >Building for iOS Simulator, but linking in object file built for ...
The second link in your question should be the same problem you have. The solution is basically add arm64 to Excluded Architecture ....
Read more >Wrong iOS simulator is launched when Xcode beta ...
The workaround is to first manually open the correct version of the simulator, in my case 11.4, and then clicking run on Visual...
Read more >Remoted iOS Simulator for Windows - Xamarin
This document describes how to wirelessly deploy a Xamarin. iOS app to an iOS device from either Visual Studio for Mac or Visual...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Eilon The stack trace looks like it comes from VS, so that’s where I believe it should go (especially since this seems like it only happens when running from the IDE, not when just building from the IDE, nor when building from the command line).
Moved to https://developercommunity.visualstudio.com/t/SolutionDir-incorrectly-maps-to-Projec/10262832?port=1025&fsid=03b64e18-549d-4c70-b8e0-d712d047aa3d