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

Add known issue for .NET tool restore in .NET 8 RC2 #8799

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions release-notes/8.0/known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,41 @@ SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" fa
File name: '...\sdk-manifests\8.0.100-rc.1\microsoft.net.workload.emscripten.current\WorkloadManifest.json'
```

### [.NET SDK 8.0.1xx RC2] `dotnet tool restore` may fail with a file access exception when restoring multiple tools

When running `dotnet tool restore` with a tools config which contains multiple .NET tools, the command can fail with an exception similar to the following:

```
Unhandled exception: System.AggregateException: One or more errors occurred. (The process cannot access the file 'C:\Users\Username\AppData\Local\Temp\a75617cf-9767-45ca-aaed-34da2edd223e\project.assets.json' because it is being used by another process.)
---> System.IO.IOException: The process cannot access the file 'C:\Users\Username\AppData\Local\Temp\a75617cf-9767-45ca-aaed-34da2edd223e\project.assets.json' because it is being used by another process.
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 NuGet.ProjectModel.LockFileFormat.Write(String filePath, LockFile lockFile)
at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.CreateAssetFile(PackageId packageId, NuGetVersion version, DirectoryPath packagesRootPath, DirectoryPath assetFileDirectory, String runtimeJsonGraph, String targetFramework) in C:\git\dotnet-sdk-8\src\Cli\dotnet\ToolPackage\ToolPackageDownloader.cs:line 329
at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.<InstallPackage>b__0() in C:\git\dotnet-sdk-8\src\Cli\dotnet\ToolPackage\ToolPackageDownloader.cs:line 130
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have any standard policy around normalizing paths in error text we include? The path is pretty generic but looks like a local git repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deterministic builds would result in cutting off the prefix portion of the path and replacing it with /_/ - so we could do that here. Replace all of the c:\git\dotnet-sdk-8 with /_/ and call it good.

Alternatively for purposes of this text we could just remove the paths entirely.

at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback) in C:\git\dotnet-sdk-8\src\Cli\dotnet\TransactionalAction.cs:line 84
at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.InstallPackage(PackageLocation packageLocation, PackageId packageId, VerbosityOptions verbosity, VersionRange versionRange, String targetFramework, Boolean isGlobalTool) in C:\git\dotnet-sdk-8\src\Cli\dotnet\ToolPackage\ToolPackageDownloader.cs:line 80
at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.InstallPackages(ToolManifestPackage package, Nullable`1 configFile) in C:\git\dotnet-sdk-8\src\Cli\dotnet\commands\dotnet-tool\restore\ToolRestoreCommand.cs:line 127
at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.<>c__DisplayClass10_0.<Execute>b__0(ToolManifestPackage package) in C:\git\dotnet-sdk-8\src\Cli\dotnet\commands\dotnet-tool\restore\ToolRestoreCommand.cs:line 96
at System.Linq.Parallel.SelectQueryOperator`2.SelectQueryOperatorResults.GetElement(Int32 index)
at System.Linq.Parallel.QueryResults`1.get_Item(Int32 index)
at System.Linq.Parallel.PartitionedDataSource`1.ListContiguousIndexRangeEnumerator.MoveNext(T& currentElement, Int32& currentKey)
at System.Linq.Parallel.StopAndGoSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
```

**Workarounds**

The error only occurs when there are multiple tools that have not been previously restored. So to work around the issue, you can remove all but one tool from the `dotnet-tools.json` config file, and run `dotnet tool restore`. Then add the tools back to the config file one at a time, running `dotnet tool restore` between each one.

If you are using .NET tools in CI where you can't easily modify the tools config file between multiple tool restores, you can create a separate `dotnet-tools.json` config file for each .NET tool in a separate subfolder. Then run `dotnet tool restore` in each subfolder.


## .NET MAUI

For details about known issues, please refer to the individual repositories:
Expand Down
Loading