dotnet / dotnet/sdk

Packing Self Contained Tool fails with multiple RIDs

Open
#51,431 0 comments 0 reactions 1 assignee Claimed by @baronfel View on GitHub
untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug
Packing a tool with multiple runtime identifiers doesn't seem to be thread safe and usually fails unless I include `-m:1` to force the rids to build sequentially rather than in parallel

### To Reproduce
With the below app, run `dotnet pack` - most of the time it fails for me, unless I run `dotnet pack -m:1`

`Whatever.csproj`
```xml


true
true
linux-x64;win-x64;any
true
true
sayhello

```

`Program.cs`
```cs
Console.WriteLine("👋 🌍");
```

### Exceptions (if any)

The exact failures vary from run to run, but it usually ends up with some file in use by another process, or a file that has been removed.

```
Restore complete (0.4s)
info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
Sample net8.0 any failed with 1 error(s) (0.4s)
CSC : error CS2012: Cannot open 'S:\ACTest\artifacts\obj\Sample\Sample.dll' for writing -- The process cannot access the file 'S:\ACTest\artifacts\obj\Sample\Sample.dll' because it is being used by another process.
Sample net8.0 win-x64 succeeded (1.0s) → S:\ACTest\artifacts\publish\Sample\
Sample net8.0 win-x64 failed with 1 error(s) (0.9s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
C:\Program Files\dotnet\sdk\10.0.100-rc.2.25502.107\NuGet.Build.Tasks.Pack.targets(222,5): error NU5019: File not found: 'S:\ACTest\artifacts\publish\Sample\Microsoft.DiaSymReader.Native.amd64.dll'.
Sample net8.0 linux-x64 succeeded (0.9s) → S:\ACTest\artifacts\publish\Sample\
Sample net8.0 linux-x64 succeeded (4.2s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
Sample net8.0 failed (0.7s) → S:\ACTest\artifacts\bin\Sample\Sample.dll

Build failed with 2 error(s) in 7.0s
```

```
Restore complete (0.4s)
info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
Sample net8.0 any succeeded (0.4s) → S:\ACTest\artifacts\publish\Sample\
Sample net8.0 any succeeded (0.5s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
Sample net8.0 win-x64 succeeded (1.1s) → S:\ACTest\artifacts\publish\Sample\
Sample net8.0 linux-x64 succeeded (1.2s) → S:\ACTest\artifacts\publish\Sample\
Sample net8.0 win-x64 failed with 1 error(s) (1.8s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
C:\Program Files\dotnet\sdk\10.0.100-rc.2.25502.107\NuGet.Build.Tasks.Pack.targets(222,5): error Could not find file 'S:\ACTest\artifacts\publish\Sample\Microsoft.DiaSymReader.Native.amd64.dll'.
Sample net8.0 linux-x64 succeeded (4.3s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
Sample net8.0 failed (0.9s) → S:\ACTest\artifacts\bin\Sample\Sample.dll

Build failed with 1 error(s) in 7.4s
```

```
Restore complete (0.3s)
info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
Sample net8.0 any succeeded (0.6s) → S:\ACTest\artifacts\publish\Sample\
Sample net8.0 any succeeded (0.2s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
Sample net8.0 win-x64 succeeded (0.9s) → S:\ACTest\artifacts\publish\Sample\
Sample net8.0 win-x64 failed with 1 error(s) (0.6s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
C:\Program Files\dotnet\sdk\10.0.100-rc.2.25502.107\NuGet.Build.Tasks.Pack.targets(222,5): error NU5019: File not found: 'S:\ACTest\artifacts\publish\Sample\aspnetcorev2_inprocess.dll'.
Sample net8.0 linux-x64 succeeded (0.8s) → S:\ACTest\artifacts\publish\Sample\
Sample net8.0 linux-x64 succeeded (3.9s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
Sample net8.0 failed (0.8s) → S:\ACTest\artifacts\bin\Sample\Sample.dll
```

### Further technical details
details of dotnet --info


.NET SDK:
Version: 10.0.100-rc.2.25502.107
Commit: 89c8f6a112
Workload version: 10.0.100-manifests.18c66609
MSBuild version: 18.0.0-preview-25502-107+89c8f6a11

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100-rc.2.25502.107\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.0-rc.2.25502.107
Architecture: x64
Commit: 89c8f6a112

.NET SDKs installed:
8.0.415 [C:\Program Files\dotnet\sdk]
9.0.306 [C:\Program Files\dotnet\sdk]
10.0.100-rc.2.25502.107 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0-rc.2.25502.107 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0-rc.2.25502.107 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.0-rc.2.25502.107 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
REDACTED

global.json file:
S:\ACTest\global.json

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.