-
Notifications
You must be signed in to change notification settings - Fork 1k
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
A simple way to package an app #630
Comments
@poma, thanks for the description of the steps. I've created some initial docs you can checkout on my docs-vs-package branch. Feel free to submit a PR based on it or send me comments of any updates and I will submit a PR. My initial thought is to keep the Package Manager GUI on the getting started and simply provide a quick link to this approach. Thanks again! |
Docs for Visual Studio Packing (Issue #630)
Using this approach I keep getting error: I've restarted VS serveral times, and the end goal is to get this to work on my Build server... Any ideas Suggestions? |
it never worked for me too |
Probably because Visual Studio can't find squirrel.exe or nuget.exe. If you have corresponding NuGet packages installed VS will load paths after you open Package Manager Console window. Otherwise just use full paths to exe files or place exe files where Windows can find them (within PATH variable). |
@poma This was a great idea. Thanks! |
My 2 Cents:
to include all subfolder recursively. |
I restarted the VS several times but still got nuget 9009 error. |
@celeron533 probably you didn't open Package Manager Console after restarting VS to scan for executable tools. I've made a pull request #830 that clarifies how to avoid that error but it is still pending. |
Version 1.5 breaks this. The Revision needs to be stripped from the Version string: |
In order to find squirrel.exe you can use MSBuild Transforms Example see @(squirrelPackage->'%(fullpath)')
|
Nice! Can you make a pull request? |
I'm facing another problem: How can i specify output dir? Am I missing smt? |
@poma's solution, with some additions from the conversation here, very nearly works for me. I'm working in VB, so there are some slight differences, but it basically works. I agree with @agostinocinelli that it seems a little off-putting to have the Releases folder showing up under the project folder and not the solution folder. I'd like to better understand the implications for multi-project solutions. Anyways, here is what worked for me:
I don't like having the versions of squirrel and Nuget in the Exec, but @Yitzchok's solution didn't work because of spaces in one of the parent directories containing this code. |
@agostinocinelli, the only thing you are missing to get Squirrel to output to another directory is the documentation for the Squirrel command-line arguments. |
I've tweaked this to the point where I'm very nearly happy. Spaces aren't a problem in full paths if they are properly quoted with
The only thing I don't like is using the AfterBuild target, which executes after every build, but it is as simple as changing the target to, say, Package, and executing MSBuild from the command-line with Package as the target. |
Hey guys, there was a formatting issue in the docs, which I've fixed with #1012 In addition, I'd like to share what I ended up with (that combines a lot of the solutions above) for the next person that comes along:
Please note (again, for the next guy) you'll need to replace the two Hope this helps someone. |
Why not replace MYAPPLICATION with a macro such as |
@poma - for me (due to the way the project has grown over time), it's because they are different. |
@PHeonix25 You'll want to put VS was giving me grief when I changed my existing project file and let it reload. It didn't like the The error messages are welcome, and already saved us a bunch of fiddling this morning. |
Created a pull request #1120 that includes all suggestions above, please review |
Reviewing that PR as well, but its been months so.. in the meantime, this is what I ended up with in order to get a well-enough functioning Maybe this would work as a slightly more understandable doc until the PR is in? It certainly helps with the props set like that (esp. releaseDir)
|
Your solution looks much cleaner. If we merge it with suggestions above result will look like: <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="myAssemblyInfo"/>
</GetAssemblyIdentity>
<PropertyGroup>
<NuGetExe>..\packages\NuGet.CommandLine.*\tools\nuget.exe</NuGetExe>
<SquirrelExe>..\packages\Squirrel.Windows.*\tools\squirrel.exe</SquirrelExe>
<SemVerNumber>$([System.Version]::Parse(%(myAssemblyInfo.Version)).ToString(3))</SemVerNumber>
<ReleaseDir>..\Releases\</ReleaseDir>
<!-- extra optional params for squirrel. can be empty -->
<SquirrelParams>--no-msi</SquirrelParams>
</PropertyGroup>
<!-- Add some nice errors for the next person that comes along -->
<Error Condition="!Exists(@(NuGetExe->'%(FullPath)'))" Text="You are trying to use the NuGet.CommandLine package, but it is not installed. Please install NuGet.CommandLine from the Package Manager." />
<Error Condition="!Exists(@(SquirrelExe->'%(FullPath)'))" Text="You are trying to use the Squirrel.Windows package, but it is not installed. Please install Squirrel.Windows from the Package Manager." />
<!-- build nupkg into the project local bin\Release\ directory temporarily -->
<Exec Command=""@(NuGetExe->'%(FullPath)')" pack $(TargetName).nuspec -Version $(SemVerNumber) -OutputDirectory $(OutDir) -BasePath $(OutDir)" />
<!-- squirrelify into the release dir (usually at solution level. Change the property above for a different location -->
<Exec Command=""@(SquirrelExe->'%(FullPath)')" --releasify $(OutDir)MyApp.$(SemVerNumber).nupkg --releaseDir=$(ReleaseDir) $(SquirrelParams)" />
</Target> And there is also question about I didn't check if this works in IDE yet. |
(scrapping previous comment) @poma I actually integrated your changes from that PR into what I am using locally. What I ended up with was essentially yours, but with the property group to keep command lines shorter/clearer, and with dotted notation instead of the
Note: I don't think what you have above will work, since I can't (on vs2017) get the <!-- manually add the item group at the root level, along with the others -->
<ItemGroup>
<!-- include nuget & squirrel with * paths. possible issue if >1 version installed -->
<NuGetCommandLine Include="..\packages\NuGet.CommandLine.*\tools\nuget.exe">
<InProject>False</InProject>
</NuGetCommandLine>
<Squirrel Include="..\packages\Squirrel.Windows.*\tools\squirrel.exe">
<InProject>False</InProject>
</Squirrel>
</ItemGroup>
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="assemblyInfo" />
</GetAssemblyIdentity>
<PropertyGroup>
<SemVerNumber>$([System.Version]::Parse(%(assemblyInfo.Version)).ToString(3))</SemVerNumber>
<NuSpecFile>MyApp.nuspec</NuSpecFile>
<ReleaseDir>..\Releases\</ReleaseDir>
<!-- extra optional params for squirrel. can be empty -->
<SquirrelParams>--no-msi</SquirrelParams>
</PropertyGroup>
<Error Condition="!Exists(%(NuGetCommandLine.FullPath))" Text="This project uses the `NuGet.CommandLine` package, but it is not installed." />
<Error Condition="!Exists(%(Squirrel.FullPath))" Text="This project uses the `Squirrel.Windows package`, but it is not installed." />
<!-- build into the local bin\Release\ directory temporarily -->
<Exec Command='"%(NuGetCommandLine.FullPath)" pack $(NuSpecFile) -Version $(SemVerNumber) -Properties Configuration=Release -OutputDirectory $(OutDir) -BasePath $(OutDir)' />
<!-- squirrelify into the release dir (usually at project level. change the property above for a different location -->
<Exec Command='"%(Squirrel.FullPath)" --releasify $(OutDir)MyApp.$(SemVerNumber).nupkg --releaseDir=$(ReleaseDir) $(SquirrelParams)' />
</Target>
|
A few more changes:
Result: <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="myAssemblyInfo" />
</GetAssemblyIdentity>
<ItemGroup>
<!-- If your .NET version is <3.5 and you get build error, move this ItemGroup outside of Target -->
<NuGetExe Include="..\packages\NuGet.CommandLine.*\tools\nuget.exe" />
<SquirrelExe Include="..\packages\Squirrel.Windows.*\tools\squirrel.exe" />
</ItemGroup>
<PropertyGroup>
<ReleaseDir>..\Releases\</ReleaseDir>
<!-- Extra optional params for squirrel. can be empty -->
<SquirrelParams>--no-msi</SquirrelParams>
<SemVerNumber>$([System.Version]::Parse(%(myAssemblyInfo.Version)).ToString(3))</SemVerNumber>
</PropertyGroup>
<!-- Add some nice errors for the next person that comes along -->
<Error Condition="!Exists(%(NuGetExe.FullPath))" Text="You are trying to use the NuGet.CommandLine package, but it is not installed. Please install NuGet.CommandLine from the Package Manager." />
<Error Condition="!Exists(%(SquirrelExe.FullPath))" Text="You are trying to use the Squirrel.Windows package, but it is not installed. Please install Squirrel.Windows from the Package Manager." />
<!-- Build nupkg into the project local bin\Release\ directory temporarily -->
<Exec Command='"%(NuGetExe.FullPath)" pack $(TargetName).nuspec -Version $(SemVerNumber) -OutputDirectory $(OutDir) -BasePath $(OutDir)' />
<!-- Squirrelify into the release dir (usually at solution level. Change the property above for a different location -->
<Exec Command='"%(SquirrelExe.FullPath)" --releasify $(OutDir)MyApp.$(SemVerNumber).nupkg --releaseDir=$(ReleaseDir) $(SquirrelParams)' />
</Target> Looks like this result is ready to be included in docs. I'll update my PR |
@poma not sure where this is all at, but it would be nice to remove the one final reference to MyApp in the squirrel exec and replace with TargetName :) |
It is fixed in the new PR #1120 |
Closing this out in favour of the PR #1120 |
I'm not sure why documentation recommends things like OctoPack and Auto.Squirrel when packaging can be easily integrated directly into build process using only nuget and squirrel. Just define a build target in .csproj file:
this will generate a nuget package from .nuspec file setting version from AssemblyInfo.cs and place it in OutDir (by default
bin\Release
). Then it will generate release files from it.Here is an example .nuget file for myApp:
Solution needs to have
nuget.exe
available for example by installingNuGet.CommandLine
package. And also it suffers from this bug when sometimes NuGet packages are not loaded properly and throwsnuget/squirrel is not recogized (9009)
errors.Other than that I think it's the simplest solution that fits most simple apps and should be recommended in Getting Started tutorial. I'm not sure whether including
nuget.exe
in squirrel package is a good practice but it could eliminate an additional dependency onNuGet.CommandLine
and make MSBuild integration work out of the box.The text was updated successfully, but these errors were encountered: