This project has moved and is read-only. For the latest updates, please go here.

Is there a way to get the full path of the package that has been generated ?

Apr 28, 2014 at 2:41 PM
I would like to retrieve the full path to the package that has been generated from the Post-build event command line, is this possible ?

Thank you.
Apr 28, 2014 at 5:03 PM
I was actually already in the process of changing the script to return just the path of the .nupkg file, as right now you would have to parse all of the output to get the path; all of the output that is currently displayed will be changed to Verbose output. So yes, it's possible, you just need to capture the output of the script and parse the file path out of it.

That is, it's possible if you are calling the New-NuGetPackage.ps1 yourself. You mention the Post-build event command line, so I assume you are using the "Create New NuGet Package From Project After Each Build" nuget package to have Visual Studio automatically create the .nupkg file for you. If this is the case, where do you plan on getting and processing that .nupkg file path? In a build script? Or from within Visual Studio somewhere? If you are doing it from Visual Studio you probably need to hook into the VS IDE using the VS SDK and pull the text from the Output window.
Apr 28, 2014 at 6:45 PM
Yes I am using "Create New NuGet Package From Project After Each Build" nuget package.

Actually I needed that to be able to move the generated package to another folder and this happens just after the block that "Create New NuGet Package From Project After Each Build" has added to "Post-build event command line".

I'll just wait for your next release :D

Thank you.
Apr 28, 2014 at 7:01 PM
Edited Apr 28, 2014 at 7:09 PM
Oh, so in the post-build event after my call you have another line to copy the .nupkg file into another directory? I'm not sure if you'll be able to capture the output of the powershell script from that cmd prompt....maybe though.

You should be able to circumvent that though by simply using the New-NuGetPackage.ps1's -OutputDirectory parameter. Just open up the PostBuildScripts\BuildNewPackage-RanAutomatically.ps1 file and change the $OutputDirectory variable to whatever directory you want the .nupkg file placed in.
Marked as answer by deadlydog on 4/28/2014 at 11:11 AM
Apr 28, 2014 at 7:11 PM
Ah yes excellent I haven't thought about that, many thanks :DDD
Apr 29, 2014 at 1:24 PM
Edited Apr 29, 2014 at 1:32 PM
There seems to be a side-effect when doing this, whenever I edit BuildNewPackage-RanAutomatically.ps1 it is now being included in the package \content folder. Even just including a comment does include it in the package.

As per your directions I changed the following
$OutputDirectory = $OutputDirectory.TrimEnd('\')
$OutputDirectory = "C:\NugetPackages"
$OutputDirectory = $OutputDirectory.TrimEnd('\')
Or to
$OutputDirectory = "C:\NugetPackages"
Also I've tried generating a nuspec file and editing but that didn't help ...

Do you have any on why it is doing this ?

PS : Actually it seems to be doing this for whatever change I might do on the file, for instance I've changed $additionalPackOptions and it does exactly the same.

Thank you.
Apr 29, 2014 at 9:11 PM
It sounds like in that file's properties (right-click the file in the VS Solution Explorer and choose Properties) the Build Action got changed to Content; it should be set to None with the Copy To Output Directory setting set to Do Not Copy.
Apr 29, 2014 at 9:56 PM
Sorry about that it seems that things got messed up somehow on my side; on all the projects
the build action is Content/Do not copy (factory settings) things but it is working now ...
the only thing being different is that I've restarted VS since then.

Thanks for your help :D
May 1, 2014 at 3:23 PM
I have been trying to get hold of this issue as it just seems that New-NuGetPackage PowerShell Script exhibits that behavior out of the box where I previously said it did happen only on that specific project.

So I've ended up crafting the following piece of code according your hint :
$dlls = @("BuildNewPackage-RanAutomatically.ps1")
$dirs = @("PostBuildScripts")
foreach ($dir in $dirs)
    foreach ($dll in $dlls)
        $item = $project.ProjectItems.Item($dir).ProjectItems.Item($dll)
        $item.Properties.Item("BuildAction").Value = 0
        $item.Properties.Item("CopyToOutputDirectory").Value = 0
(to be pasted just above $project.Save() in install.ps1)

That works quite well, no matter what changes I do make on the file it won't be included then !

The thing is that it seems that nuget has a bug in the sense that even if developmentDependency="true" for your package in packages.config it will include the changed scripts on the generated package (very annoying !).

Hopefully you'll be interested in interested in integrating such behavior on your project :D

Thank you.
May 3, 2014 at 5:53 PM
Thanks Aybe. I've tried several times and am unable to reproduce this issue of the scripts getting included in the Content folder of the generated package. Unless I explicitly change the file's Build Action property to Content, everything works as expected, no matter how much I edit those files.

Since I am unable to reproduce this problem and nobody else has reported it, I'm going to leave your fix out. If others do report it though then I'll include it. Thanks for the code and the heads up :)
May 5, 2014 at 4:29 PM
I guess my Visual Studio installation is broken then ... I can't remember what was the original setting that your package defines for the scripts, currently it sets everything to Content.

Thanks :D
May 5, 2014 at 5:26 PM
The Build Action should be set to None with the Copy To Output Directory setting set to Do Not Copy.