-
Notifications
You must be signed in to change notification settings - Fork 252
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
NuGet.exe restore: allow specifying Solution Configuration to use for .sln, for example -Properties similar to pack. #7575
Comments
You can already achieve that with an environment variable.
Furthermore in PackageReference NuGet itself does not use the Configuration when evaluating Package/ProjectReferences, so not sure relying on NuGet to play well with these Configuration conditions imports is a good idea. |
@nkolev92 - instead of specifically for a restore, perhaps this is for installing a development or debug tool inclusion? Some additional logging or tracing that only needs to be present for debug configuration, or even something like non-minified JS for a web project. Or maybe the opposite; something that needs to only be included on a release or production build. |
There are cases where MSBuild properties need to be set in order to have a valid parsable project file, while the environment variable works having a generic way to specify multiple msbuild properties on the command line would be handy. Doing |
This issue is reported in 2018. |
I managed to workaround the issue by setting NUGET_RESTORE_MSBUILD_ARGS to /p:Platform=$(BuildPlatform) /p:Configuration=$(BuildConfiguration) in my Azure DevOps pipeline. Without this NuGet parses all csproj files with no Platform value set and it defaults to Debug because of this msbuild line: So with Choose/When/Otherwise in combination of NUGET_RESTORE_MSBUILD_ARGS I was able to run csproj files with conditional MSBuild ItemGroup elements in Visual Studio and in Azure DevOps. It would be nice to be able to set properties via command line and also in AzDo NuGet step as @mletterle proposes. |
I think a Properties option like @mletterle suggests is the direction here instead of a configuration specific switch. |
Yes, I'd love to have that. That would be a better and more general solution. |
Note that I'm not sure we'll be able to get this to this soon, but we'd be open to taking a contribution. |
|
All you do when when you specify that env variable is that NuGet passes that to msbuild when evaluating projects. |
Please ignore - it was related to something else. |
Details about Problem
NuGet product used: NuGet.exe
NuGet version (x.x.x.xxx):
4.9.1.5694
dotnet.exe --version (if appropriate):
2.2.0-preview1-007622
VS version (if appropriate): 15.9.2
OS version (i.e. win10 v1607 (14393.321)): Win10
Worked before? If so, with which NuGet version: not a regression
Detailed repro steps so we can see the same problem
Have an .sln file with two configurations: Debug and Release.
Have a project that only fails to build in Debug.
You should be able to restore nuget packages by specifying:
nuget restore My.sln /Configuration Release
Currently restore fails because nuget chooses the default (Debug) configuration which doesn't build.
Unfortunately the workaround of using
msbuild /r /p:Configuration=Release
ordotnet restore
doesn't work because many solutions still include projects that have no understanding of NuGet, and so the Restore target isn't there.The text was updated successfully, but these errors were encountered: