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

No dotnet restore --configuration option #7050

Closed
livarcocc opened this issue Jun 21, 2018 · 6 comments
Closed

No dotnet restore --configuration option #7050

livarcocc opened this issue Jun 21, 2018 · 6 comments
Labels
Functionality:Restore Resolution:Duplicate This issue appears to be a Duplicate of another issue Style:PackageReference Type:DCR Design Change Request

Comments

@livarcocc
Copy link

From @bcuff on June 21, 2018 22:52

Steps to reproduce

Create a csproj file with conditional package references

Example:

<ItemGroup Condition="'$(Configuration)' == 'NUnitLite'">
    <PackageReference Include="NUnitLite" Version="3.9.0" />
</ItemGroup>

Expected behavior

dotnet restore should respect the --configuration parameter.

dotnet restore --configuration NUnitLite

Actual behavior

dotnet restore doesn't have a --configuration option

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.201)

Product Information:
 Version:            2.1.201
 Commit SHA-1 hash:  7932dc6179

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.201\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11

Copied from original issue: dotnet/cli#9537

@nkolev92
Copy link
Member

nkolev92 commented Jun 25, 2018

Duplicate of #5421 and #5895.

As indicated in #5895 (comment),

TargetFramework is the only support condition allowed for PackageReference items.

To work with other conditions you will need to handle them yourself by passing the extra property values to restore, and ensuring that restore is done appropriately before each build.

@nkolev92 nkolev92 added Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:DCR Design Change Request Functionality:Restore Style:PackageReference labels Jun 25, 2018
@turowicz
Copy link

turowicz commented May 7, 2019

@nkolev92 this is not about where to put conditions in, this is about the ability to pass a configuration or any other variable to the dotnet restore command, as it is possible in the dotnet build. In my case dotnet build -c Release restores correctly with the Configuration condition, while dotnet restore seems to be restoring without Configuration condition evaluation.

@nkolev92
Copy link
Member

nkolev92 commented May 8, 2019

dotnet build implicitly invokes restore.
The implicit restore is exactly the same as the dotnet restore command.

Restore does not evaluate based on the Configuration pivot.

So dotnet restore, dotnet restore /p:Configuration="Release" dotnet build, dotnet build -c Release will all run the same restore.

You can verify that by consecutively running all these commands and seeing that the timestamps of the assets file do not change.

@turowicz
Copy link

turowicz commented May 8, 2019

I've found a workaround with:

RUN dotnet msbuild /t:restore /p:Configuration=Release src

It really does evaluate the condition and references the right package. In Debug I reference a nuget package while in Release I point to a localy compiled dll.

@turowicz
Copy link

turowicz commented May 8, 2019

Additionaly, for people running Docker, it is very important that the restore is a separate command from build. In that scenario build is invoked with --no-restore flag.

@jonathanantoine
Copy link

Thank you @turowicz . By the way, it works also this way :
dotnet restore /p:Configuration=Release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Resolution:Duplicate This issue appears to be a Duplicate of another issue Style:PackageReference Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

4 participants