NuGet.exe needs to support additional build parameters

Apr 22, 2011 at 4:56 PM

I have a project that is using the "unsafe" flag in order to allow me to do certain operations.
When I try to use NuGet.exe to create a package based on the csproj file I get the following error:
error CS0227: Unsafe code may only appear if compiling with /unsafe

It would be nice if when calling the nuget.exe file we were given a way to specify additional build arguments.

Developer
Apr 22, 2011 at 5:51 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 23, 2011 at 3:39 AM

@dfowler: I was wondering if you can show me a quick sample of being able to specify the Exclude argument for the pack command because it is a ICollection<string> property on the PackCommand and I am trying to implement the BuildArgs property to allow me to do something like:

NuGet pack someproject.csproj BuildArgs "/unsafe;/somethingelse=true"

Or can you make a recommendation on the syntax that one can use to provide additional arguments to the Project Factory class.

Developer
Apr 23, 2011 at 4:18 AM

I think we'd want to use an IDictionary<string, string> and then copy the msbuild syntax i.e.

/p A=B;C=D

Apr 23, 2011 at 3:54 PM

I am running into a small issue here. I got the command line parsing logic all working however when the ProjectFactory.BuildProject logic tries to run it throws an exception because the BuildRequestData does not seem to allow arguments to be passed in that don't have a value such as when I try to pass in just the single /unsafe flag. This is what the current command line statement looks like:
nuget.exe pack someproject.csproj -BuildArgs /unsave

Any thoughts? I can't seem to find any documentation that would point me in the direction of being able to specify a property that does not have a value.

Apr 23, 2011 at 4:58 PM

I think I figured it out. The "/unsafe" switch is just a shortcut to specify the AllowUnsafeBlocks=true property to the build engine.

Developer
Apr 23, 2011 at 5:29 PM

If you ran msbuild on your project does it just work? If it does, we need to figure out why the ProjectFactory doesn't work just like the exe (it should).

Apr 23, 2011 at 7:05 PM

Yes, when I run msbuild someproject.csproj then it works just fine.

fyi, I am creating a new fork with an implementation that I have tested and it is working where I've added a new property which is Dictionary<string,string> that allows you to specify a ";" delimited list of parameters that will be passed on to the build engine.
The sample command looks like this:  nuget.exe -BuildArgs Configuration=true;AllowUnsafeBlocks=true

Developer
Apr 23, 2011 at 10:01 PM

There's 2 distinct issues we're dealing with here:

  1. Having the ability to pass arguments.
  2. Figuring out why msbuild works without the need to pass those extra arguments.

We need to figure out #2.

Also, for #1 I'd prefer if the property was called Properties so that we could also use it when building a package from a nuspec file ($token$ replacement).

Apr 23, 2011 at 10:06 PM

Not sure about #2 will have to look into it some more.
About #1, I couldn't think of a better name so I'll go ahead and change it to Properties.

I was hoping that I can start using the ReviewBoard and I was wondering if you could help me get it setup and running or someone from the dev group.
I am not able to post a new review. I am getting an error when I try to publish and now TortoiseHg is crashing on me.
Can you tell me which version of Mercurial that you are using and the revision of the mercurial-reviewboard extension so that I can try the same ones that might work better with your version of reviewboard.