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

Self-contained publish/build error #21677

Closed
bradygaster opened this issue Oct 1, 2021 · 6 comments · Fixed by dotnet/msbuild#6924
Closed

Self-contained publish/build error #21677

bradygaster opened this issue Oct 1, 2021 · 6 comments · Fixed by dotnet/msbuild#6924
Assignees
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@bradygaster
Copy link
Member

Describe the bug

When I try to do a self-contained build and publish of an app I wish to publish to App Service prior to RC2 being on it, I am seeing errors, and as such am blocked from being able to build a self-contained publish package.

To Reproduce

I have an example repository here: https://github.com/bradygaster/TodoApp

It contains two projects in one VS solution. It also contains a setup.ps1 file you can run to see the issue. One of the projects will build and publish just fine, the second will build but when the publish command runs this error is visible:

C:\Program Files\dotnet\sdk\6.0.100-rc.2.21501.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(150,5): error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier. You must either specify a RuntimeIdentifier or set SelfContained to false. [C:\Users\brady\source\TodoApp\TodoApp.API\TodoApp.API.csproj]

Further technical details

My dotnet-version is:

❯ dotnet --version
6.0.100-rc.2.21501.4

And dotnet --info is:

.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.2.21501.4
 Commit:    18c7fa28d1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-rc.2.21501.4\

Host (useful for support):
  Version: 6.0.0-rc.2.21470.23
  Commit:  826f81a11a

.NET SDKs installed:
  5.0.301 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.1.21370.1 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.1.21458.32 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21467.17 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21501.4 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21470.37 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21375.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21470.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.7.21369.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.1.21451.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21470.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

@richlander asked me to file this when I showed him the issue, and that I cc @sfoslund in the issue. Thanks to the team for your hard work!

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Oct 1, 2021
@richlander
Copy link
Member

Dupe of #21560? Do we just need to wait until tomorrow's build @sfoslund?

@sfoslund
Copy link
Member

sfoslund commented Oct 1, 2021

Dupe of #21560?

No, this is a different error (NETSDK1031, not NETSDK1179).

@bradygaster, do you see this error with previous versions of the SDK or is it just with RC2? It looks like one of the project references is failing to build because it does not have a runtime identifier specified. @dsplaisted do we expect that a RID will be passed to all referenced projects when published?

@dsplaisted
Copy link
Member

I think what's happening is we prevent the RuntimeIdentifier property from flowing to project references, but we don't stop the SelfContained property from flowing, so in this case when it tries to build the referenced project it fails because SelfContained is specified but RuntimeIdentifier isn't.

Probably we should stop SelfContained from flowing the same way we stop RuntimeIdentifier.

@rainersigwald

@richlander
Copy link
Member

richlander commented Oct 2, 2021

@bradygaster Is this the line that is producing the error? https://github.com/bradygaster/TodoApp/blob/0decfd788b9952633c24afc17e2f3fe978fc1ca7/setup.ps1#L23

As an aside, this command can now be simplified, from:

dotnet publish TodoApp.API\TodoApp.API.csproj --self-contained -r win-x86 -o publish\api

to

dotnet publish TodoApp.API\TodoApp.API.csproj --sc -a x86 -o publish\api

Note: this assumes the command is always run on Windows.

@rainersigwald
Copy link
Member

Probably we should stop SelfContained from flowing the same way we stop RuntimeIdentifier.

Sounds reasonable to me.

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

Successfully merging a pull request may close this issue.

6 participants