dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.66k stars 1.06k forks source link

`dotnet publish` fails on .NET SDK 8.0.100 #37118

Open junlinz2 opened 9 months ago

junlinz2 commented 9 months ago

Describe the bug

dotnet publish fails when trying to use the .NET 8 win-x64 RID as suggested by this breaking change. This is observed in MAUI as we are trying to publish MSIX applications that use MAUI, however it might affect other frameworks as well. Instead, the following message is shown:

C:\Users\user\.nuget\packages\microsoft.windowsappsdk\1.3.230724000\buildTransitive
\Microsoft.Build.Msix.Packaging.targets(1036,5):
error : Packaged .NET applications with an app host exe cannot be ProcessorArchitecture neutral.
Please specify a RuntimeIdentifier or a Platform other than AnyCPU. [C:\A\M\HelloWorld\HelloWorld
.csproj::TargetFramework=net8.0-windows10.0.19041.0]

To Reproduce

This is tested on .NET 8.0.100 and .NET MAUI 8.0.3, using Windows 11 21H2:

  1. dotnet new maui --name "HelloWorld"
  2. cd HelloWorld
  3. dotnet publish --configuration Release --self-contained --framework "net8.0-windows10.0.19041.0" --runtime "win-x64"

Expected: MSIX package should be produced without errors. This worked on .NET 7.0.402, MAUI 7.0.96. Actual: the log output above is produced and the publish fails.

Exceptions (if any)

N/A

Further technical details

.NET SDK:
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.71b9f198

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Users\user\dotnet\sdk\8.0.100\

.NET workloads installed:
 Workload version: 8.0.100-manifests.71b9f198
 [maui]
   Installation Source: SDK 8.0.100
   Manifest Version:    8.0.3/8.0.100
   Manifest Path:       C:\Users\user\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json
   Install Type:        FileBased

 [android]
   Installation Source: VS 17.8.34309.116, VS 17.8.34112.27
   Manifest Version:    34.0.43/8.0.100
   Manifest Path:       C:\Users\user\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.43\WorkloadManifest.json
   Install Type:        FileBased

 [maui-windows]
   Installation Source: VS 17.8.34309.116, VS 17.8.34112.27
   Manifest Version:    8.0.3/8.0.100
   Manifest Path:       C:\Users\user\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json
   Install Type:        FileBased

 [maccatalyst]
   Installation Source: VS 17.8.34309.116, VS 17.8.34112.27
   Manifest Version:    17.0.8478/8.0.100
   Manifest Path:       C:\Users\user\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.0.8478\WorkloadManifest.json
   Install Type:        FileBased

 [ios]
   Installation Source: VS 17.8.34309.116, VS 17.8.34112.27
   Manifest Version:    17.0.8478/8.0.100
   Manifest Path:       C:\Users\user\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.0.8478\WorkloadManifest.json
   Install Type:        FileBased

Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71

.NET SDKs installed:
  7.0.200 [C:\Users\user\dotnet\sdk]
  7.0.306 [C:\Users\user\dotnet\sdk]
  7.0.400 [C:\Users\user\dotnet\sdk]
  7.0.401 [C:\Users\user\dotnet\sdk]
  8.0.100 [C:\Users\user\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.11 [C:\Users\user\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0 [C:\Users\user\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.11 [C:\Users\user\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0 [C:\Users\user\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 7.0.11 [C:\Users\user\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0 [C:\Users\user\dotnet\shared\Microsoft.WindowsDesktop.App]

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

Environment variables:
  Not set

global.json file:
  Not found

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

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

The above was tested using a standalone install of .NET with MAUI workloads installed. But I can also repro this issue with the version of .NET that Visual Studio installs as well, again using .NET SDK 8.0.100. The publish works in Visual Studio 17.8 but I presume it's because Visual Studio itself is still using the previous RID graph:

image

e012345678 commented 9 months ago

Having the same issue.

johngraumann commented 9 months ago

Same issue here as well. This is preventing us from releasing our app with .NET 8.

bengavin commented 9 months ago

Same issue here, compiling on an M2 MacBook Pro under Parallels. I can get a little further by specifying -p:Platform=x64 -r win-x64, but then I get the following error. It's trying to pull a dependency from both the 'root' dependency bin folder -AND- from the win-x64 sub-directory and flagging that as an error. However, the file doesn't actually exist in the win-x64 subdirectory at all.

APPX1101: Payload contains two or more files with the same destination path

Project structure:

The error message gives essentially: ....nuget\packages\microsoft.windowsappsdk\1.3.230724000\buildTransitive\Microsoft.Build.Msix.Packaging. targets(1500,5): error APPX1101: Payload contains two or more files with the same destination path 'App.Mvvm .pdb'. Source files: [....csproj::TargetFramework=net8.0 -windows10.0.22621.0] ....nuget\packages\microsoft.windowsappsdk\1.3.230724000\buildTransitive\Microsoft.Build.Msix.Packaging. targets(1500,5): error APPX1101: ...App.Mvvm\bin\x64\Release\net8.0-windows 10.0.22621.0\App.Mvvm.pdb [...App.csproj::TargetF ramework=net8.0-windows10.0.22621.0] ....nuget\packages\microsoft.windowsappsdk\1.3.230724000\buildTransitive\Microsoft.Build.Msix.Packaging. targets(1500,5): error APPX1101: ...\App.Mvvm\bin\x64\Release\net8.0-windows 10.0.22621.0\win-x64\App.Mvvm.pdb [...\App.csproj: :TargetFramework=net8.0-windows10.0.22621.0]

ghost commented 9 months ago

Same issue here as well. This is preventing us from releasing our app with .NET 8.

Did you get a fix? I am trying to release my software ASAP and need an executable. Would there be anyone online that could help? When is the next patch for dotnet maui?

IgorMarkiv commented 8 months ago

Same issue.

erossini commented 8 months ago

Same issue here. Is there any solution?

NJullienSweet commented 8 months ago

Drop the --runtime win-x64 from your command line to make it publish for a runtime called win10-x64

johannes-steurer commented 7 months ago

With above suggestion this seems to work for me: dotnet publish --configuration Release --self-contained --framework "net8.0-windows10.0.19041.0"

hughesjs commented 7 months ago

I seem to get this issue doing a dotnet build -c Release too

e012345678 commented 7 months ago

Adding /p:UseRidGraph=true to the publish command resolved this issue for us

hughesjs commented 7 months ago

@e012345678 - What does that actually do? The docs are pretty light on the matter... Have you noticed any downsides?

Stefano-Buzzoni commented 4 months ago

Is anybody using 'Individual Accounts' as authentication method and finding problems on releasing the app on IIS?

jinge1936 commented 3 weeks ago

why ms tech stack sucks so much, a known issue could exist for so long time without any fix or workaround.

NJullienSweet commented 3 weeks ago

why ms tech stack sucks so much, a known issue could exist for so long time without any fix or workaround.

@jinge1936 My workaround doesn't work for you? https://github.com/dotnet/sdk/issues/37118#issuecomment-1870104929

jinge1936 commented 3 weeks ago

@NJullienSweet ,

I resolved the issue , and shared my solution in stackoverflow in which redirect me to here.

jinge1936 commented 3 weeks ago

I am sure it's a bug in dotnet sdk8 for target windows, the issue does not happen in macOS.

jinge1936 commented 3 weeks ago

So disappointed , I haven't used dotnet to write tools for so long a time, in my mind, c# ,dotnet is best tools in the market, but it looks now it's painful to use. write one tools , having so many bugs. Cannot find solution with search engines, and all llms.