Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.0.200 breaks "dotnet workload restore ..\some.sln" #47390

Closed
AArnott opened this issue Mar 8, 2025 · 2 comments
Closed

9.0.200 breaks "dotnet workload restore ..\some.sln" #47390

AArnott opened this issue Mar 8, 2025 · 2 comments
Labels
Area-Workloads untriaged Request triage from a team member

Comments

@AArnott
Copy link
Contributor

AArnott commented Mar 8, 2025

Describe the bug

dotnet workload restore ..\my.sln fails, because project paths in the sln file are evaluated based on the current directory instead of the sln directory.

To Reproduce

In an empty directory, run the following commands:

md repro
cd repro
dotnet new sln
dotnet new classlib -o lib
dotnet sln add lib
cd lib
dotnet workload restore ..\repro.sln

This fails, while dotnet workload restore from the sln directory succeeds.

This worked in .NET SDK 9.0.103. It broke in 9.0.200.

Exceptions (if any)

Updated advertising manifest microsoft.net.workload.emscripten.net6.
Updated advertising manifest microsoft.net.sdk.aspire.
Updated advertising manifest microsoft.net.sdk.maui.
Updated advertising manifest microsoft.net.workload.mono.toolchain.current.
Updated advertising manifest microsoft.net.sdk.ios.
Updated advertising manifest microsoft.net.sdk.maccatalyst.
Updated advertising manifest microsoft.net.workload.mono.toolchain.net6.
Updated advertising manifest microsoft.net.workload.emscripten.net8.
Updated advertising manifest microsoft.net.workload.emscripten.current.
Updated advertising manifest microsoft.net.workload.mono.toolchain.net8.
Updated advertising manifest microsoft.net.sdk.tvos.
Updated advertising manifest microsoft.net.workload.mono.toolchain.net7.
Updated advertising manifest microsoft.net.sdk.android.
Updated advertising manifest microsoft.net.sdk.macos.
Updated advertising manifest microsoft.net.workload.emscripten.net7.
Warning: Workload garbage collection failed with error: An error occurred trying to start process '"C:\Program Files\dotnet\dotnet.exe"' with working directory 'D:\temp\repro\lib'. The operation was canceled by the user..

Successfully updated workload(s): android aspire ios maccatalyst maui-windows wasm-tools wasm-tools-net7.

Unhandled exception: Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Could not find a part of the path 'D:\temp\repro\lib\lib\lib.csproj'.  D:\temp\repro\lib\lib\lib.csproj
 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\temp\repro\lib\lib\lib.csproj'.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.Build.Internal.XmlReaderExtension..ctor(String file, Boolean loadAsReadOnly)
   at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting, Boolean loadAsReadOnly)
   --- End of inner exception stack trace ---
   at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
   at Microsoft.Build.Shared.ProjectFileErrorUtilities.ThrowInvalidProjectFile(BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
   at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting, Boolean loadAsReadOnly)
   at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCacheBase projectRootElementCache, Boolean preserveFormatting)
   at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, ProjectRootElementCacheBase projectRootElementCache, Boolean preserveFormatting)
   at Microsoft.Build.Evaluation.ProjectRootElementCache.GetOrLoad(String projectFile, OpenProjectRootElement loadProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting)
   at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement loadProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting)
   at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCacheBase projectRootElementCache, Boolean isExplicitlyLoaded)
   at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, Nullable`1 projectLoadSettings, EvaluationContext evaluationContext, IDirectoryCacheFactory directoryCacheFactory, Boolean interactive)
   at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion)
   at Microsoft.DotNet.Workloads.Workload.Restore.WorkloadRestoreCommand.RunTargetToGetWorkloadIds(IEnumerable`1 allProjects)
   at Microsoft.DotNet.Workloads.Workload.Restore.WorkloadRestoreCommand.<>c__DisplayClass3_0.<Execute>b__1()
   at Microsoft.DotNet.Workloads.Workload.WorkloadHistoryRecorder.Run(Action workloadAction)
   at Microsoft.DotNet.Workloads.Workload.Restore.WorkloadRestoreCommand.Execute()
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at System.CommandLine.ParseResult.Invoke()
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Mar 8, 2025
AArnott added a commit to nerdcash/Nerdbank.Cryptocurrencies that referenced this issue Mar 8, 2025
This is a workaround for dotnet/sdk#47390.
@baronfel
Copy link
Member

baronfel commented Mar 8, 2025

cc @edvilme - is this a result of the slnx parser work?

@edvilme
Copy link
Member

edvilme commented Mar 10, 2025

Hello @baronfel, not with the parser itself, but with the refactorings.

WorkloadRestoreCommand.DiscoverAllProjects returns the project paths relative to the solution file. Hence when passed to WorkloadRestoreCommand.RunTargetToGetWorkloadIds it tries to resolve as if it were relative to the current working directory.

This is a bug and WorkloadRestoreCommand.DiscoverAllProjects should return the full path instead.


Should be fixed by #47415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Workloads untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

5 participants