This project is read-only.
1

Closed

NuGet pack does not propagate Properties to msbuild

description

Steps to reproduce:
1 - Create a C# project (example.csproj) without an "AnyCPU" platform (i.e. x86 only)
2 - Create a .nuspec for the project.
3 - Using version 2.2.0, run NuGet.exe pack example.csproj -Build -Properties Configuration=Release;Platform=x86

Expected results:
1 - example is built in Release/x86
2 - NuGet package is built with that output

Actual results:
"""
Attempting to build package from 'example.csproj'.
Building project for target framework '.NETFramework,Version=v4.0'.

Project "W:\Source...\example\example.csproj" (default targets):

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(609,5): error : The OutputPath property is not set for project 'example.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.
Done building project "example.csproj" -- FAILED.
Failed to build 'example.csproj'.
"""

Notes:
ProjectFactory's BuildProject() provides only ProjectProperties to the constructor of BuildRequestData (line 283). ProjectProperties contains just one property (SolutionDir). _project.Properties contains 403 properties on my system, including Configuration and Platform as they were set in step 3.

file attachments

Closed Jan 24, 2013 at 9:50 PM by deepakverma
Verified it works fine after the fix for 2.2.1 nuget.exe

comments

OliIsCool wrote Dec 20, 2012 at 11:12 PM

FYI, I have submitted a pull request to fix this in Master http://nuget.codeplex.com/SourceControl/network/forks/OliIsCool/PropagatePropertiesToMsBuild/contribution/3837 and one to fix this in the 2.2 branch http://nuget.codeplex.com/SourceControl/network/forks/OliIsCool/PropagatePropertiesToMsBuild/contribution/3836. It's the same code in both branches, including an integration test to reproduce/expose the defect.

ClayCompton wrote Dec 21, 2012 at 2:07 AM

@howarddierking - No. I'm not seeing anything like the error described here. I can't reproduce this with the current stable NuGet.exe and a console application project that's been permuted to have a platform target of x86.

OliIsCool wrote Dec 21, 2012 at 3:16 AM

I have attached the generated files created by the new NuGetCommandLineTest.PackageCommand_WhenSpecifyingProjectFilePropertiesArePropagatedToMsBuild() test.

Unzip them to a folder and run:
nuget pack -Build -Properties Configuration=Release;Platform=x86

Notice the LegacyProcessorProject.csproj file only defines OutputPath when Platform is x86 (lines 20 and 28), but the default value for Platform (when the Properties aren't being propagated) is set on line 5. Similarly, Configuration is initialized on line 4 if it wasn't already provided. The error message from MSBuild includes the current values for Configuration and Platform at the time of error and they are clearly not the ones specified on the command line.

Even if line 5 of the project file initialized Platform to x86 if it wasn't specified, I would still end up with a Debug-built assembly when I clearly asked for a Release one.

ClayCompton wrote Dec 21, 2012 at 3:25 AM

Oli -- thanks. Re-assigning back to triage.

dotnetjunky wrote Dec 21, 2012 at 6:04 AM

I have accepted the pull request. We were hit by this issue in the NuGet solution build ourselves.