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 fails when explicit restore is run beforehand with -r #2312

Closed
MichaelSimons opened this issue Jun 6, 2018 · 5 comments
Assignees
Milestone

Comments

@MichaelSimons
Copy link
Member

MichaelSimons commented Jun 6, 2018

Repo Steps

  1. Install cli 2.1.301-preview-008906
  2. mkdir app
  3. dotnet new console --no-restore
  4. dotnet restore -r linux-musl-x64
  5. dotnet publish -c Release -o /sandbox --no-restore -r linux-musl-x64

Actual Results

You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452
/app2/app2.csproj : error : The project was restored using Microsoft.NETCore.App version 2.1.0, but with current settings, version 2.1.1-servicing-26605-02 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore.

Expected Results

Publishing would succeed.

Regression appears to be caused by #2085
Related to #1570

@eerhardt
Copy link
Member

eerhardt commented Jun 6, 2018

/cc @dsplaisted

Looking into this, it appears that dotnet restore -r linux-musl-x64 sets the RuntimeIdentifiers (note plural) property during Restore. Which means that SelfContained=false. Thus when you dotnet restore -r linux-musl-x64, it thinks you are not a self-contained app, which means it restores for 2.1.0.

Then later when you dotnet publish --no-restore -r linux-musl-x64, the -r linux-musl-x64 sets the RuntimeIdentifier (note NOT plural) property, which means SelfContained=true. Thus it wants to use 2.1.1-servicing (the latest patch).

MichaelSimons added a commit to MichaelSimons/dotnet-docker that referenced this issue Jun 6, 2018
@livarcocc livarcocc added this to the 2.1.4xx milestone Jun 6, 2018
@MichaelSimons
Copy link
Member Author

@livarcocc - curious why this was added to the 2.1.4xx milestone when this was a regression introduced in 2.1.301?

@livarcocc
Copy link
Contributor

I believe this is a regression between 2.1.2xx and 2.1.3xx, not within 2.1.3xx. That's when we introduced the self-publish work to guarantee that self-contained apps would publish for the highest runtime we knew of.

@dsplaisted
Copy link
Member

This was an intentional change in 2.1.300. If you want to publish as self-contained but use --no-restore, you can set the TargetLatestRuntimePatch property in your project to true. See the docs on Self-contained deployment runtime roll forward for more details.

@livarcocc
Copy link
Contributor

Closing this as by design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants