Skip to content

Commit

Permalink
NuGet packages correctly build and place the output in the package fo…
Browse files Browse the repository at this point in the history
…lder.
  • Loading branch information
[email protected] committed May 17, 2012
1 parent f178ca4 commit 6e50867
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Core/Nuspec/Autofac.Mef/Autofac.Mef.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Autofac.Mef</id>
<version>0.0.0.0</version>
<version>$version$</version>
<authors>Autofac Contributors</authors>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand All @@ -13,7 +13,7 @@
<projectUrl>http://autofac.org</projectUrl>
<iconUrl>http://code.google.com/p/autofac/logo</iconUrl>
<dependencies>
<dependency id="Autofac" version="0.0.0.0" />
<dependency id="Autofac" version="$version$" />
</dependencies>
</metadata>
</package>
30 changes: 30 additions & 0 deletions Core/Nuspec/Autofac.Mef/NuspecStaging.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Stage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Target Name="Stage">
<Error Text="You must specify the project binary output directory." Condition="'$(BuildBinDirectory)' == ''" />
<Error Text="You must specify the Nuspec staging directory." Condition="'$(StagingDirectory)' == ''" />
<PropertyGroup>
<!-- The name of the .nuspec file being staged, minus extension. -->
<NuspecName>Autofac.Mef</NuspecName>
</PropertyGroup>
<ItemGroup>
<!--
Staging goes in build_output\package\nuspec-staging\NuspecName so the
master build script can run NuGet and package it all up.
Select which assemblies from the root build_output folder get included.
Everything else will get staged automatically.
-->
<LibFiles Include="
$(BuildBinDirectory)\**\Autofac.Integration.Mef.dll;
$(BuildBinDirectory)\**\Autofac.Integration.Mef.xml" />
<ProjectFiles Include="$(MSBuildProjectDirectory)\**\*.*" Exclude="$(MSBuildProjectDirectory)\NuspecStaging.proj;$(MSBuildProjectDirectory)\*.nuspec" />
</ItemGroup>

<!-- Copy the .nuspec, other project files in this folder, and requisite lib files into a staging area for packaging. -->
<MakeDir Directories="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(NuspecName).nuspec" DestinationFolder="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="%(ProjectFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\%(ProjectFiles.RecursiveDir)%(ProjectFiles.Filename)%(ProjectFiles.Extension)" />
<Copy SourceFiles="%(LibFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\lib\%(LibFiles.RecursiveDir)%(LibFiles.Filename)%(LibFiles.Extension)" />
</Target>
</Project>
4 changes: 2 additions & 2 deletions Core/Nuspec/Autofac.Mvc3/Autofac.Mvc3.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Autofac.Mvc3</id>
<version>0.0.0.0</version>
<version>$version$</version>
<authors>Autofac Contributors</authors>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand All @@ -13,7 +13,7 @@
<projectUrl>http://autofac.org</projectUrl>
<iconUrl>http://code.google.com/p/autofac/logo</iconUrl>
<dependencies>
<dependency id="Autofac" version="0.0.0.0" />
<dependency id="Autofac" version="$version$" />
</dependencies>
</metadata>
</package>
30 changes: 30 additions & 0 deletions Core/Nuspec/Autofac.Mvc3/NuspecStaging.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Stage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Target Name="Stage">
<Error Text="You must specify the project binary output directory." Condition="'$(BuildBinDirectory)' == ''" />
<Error Text="You must specify the Nuspec staging directory." Condition="'$(StagingDirectory)' == ''" />
<PropertyGroup>
<!-- The name of the .nuspec file being staged, minus extension. -->
<NuspecName>Autofac.Mvc3</NuspecName>
</PropertyGroup>
<ItemGroup>
<!--
Staging goes in build_output\package\nuspec-staging\NuspecName so the
master build script can run NuGet and package it all up.
Select which assemblies from the root build_output folder get included.
Everything else will get staged automatically.
-->
<LibFiles Include="
$(BuildBinDirectory)\**\Autofac.Integration.Mvc.dll;
$(BuildBinDirectory)\**\Autofac.Integration.Mvc.xml" />
<ProjectFiles Include="$(MSBuildProjectDirectory)\**\*.*" Exclude="$(MSBuildProjectDirectory)\NuspecStaging.proj;$(MSBuildProjectDirectory)\*.nuspec" />
</ItemGroup>

<!-- Copy the .nuspec, other project files in this folder, and requisite lib files into a staging area for packaging. -->
<MakeDir Directories="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(NuspecName).nuspec" DestinationFolder="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="%(ProjectFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\%(ProjectFiles.RecursiveDir)%(ProjectFiles.Filename)%(ProjectFiles.Extension)" />
<Copy SourceFiles="%(LibFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\lib\%(LibFiles.RecursiveDir)%(LibFiles.Filename)%(LibFiles.Extension)" />
</Target>
</Project>
4 changes: 2 additions & 2 deletions Core/Nuspec/Autofac.Wcf/Autofac.Wcf.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Autofac.Wcf</id>
<version>0.0.0.0</version>
<version>$version$</version>
<authors>Autofac Contributors</authors>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand All @@ -13,7 +13,7 @@
<projectUrl>http://autofac.org</projectUrl>
<iconUrl>http://code.google.com/p/autofac/logo</iconUrl>
<dependencies>
<dependency id="Autofac" version="0.0.0.0" />
<dependency id="Autofac" version="$version$" />
</dependencies>
</metadata>
</package>
30 changes: 30 additions & 0 deletions Core/Nuspec/Autofac.Wcf/NuspecStaging.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Stage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Target Name="Stage">
<Error Text="You must specify the project binary output directory." Condition="'$(BuildBinDirectory)' == ''" />
<Error Text="You must specify the Nuspec staging directory." Condition="'$(StagingDirectory)' == ''" />
<PropertyGroup>
<!-- The name of the .nuspec file being staged, minus extension. -->
<NuspecName>Autofac.Wcf</NuspecName>
</PropertyGroup>
<ItemGroup>
<!--
Staging goes in build_output\package\nuspec-staging\NuspecName so the
master build script can run NuGet and package it all up.
Select which assemblies from the root build_output folder get included.
Everything else will get staged automatically.
-->
<LibFiles Include="
$(BuildBinDirectory)\**\Autofac.Integration.Wcf.dll;
$(BuildBinDirectory)\**\Autofac.Integration.Wcf.xml" />
<ProjectFiles Include="$(MSBuildProjectDirectory)\**\*.*" Exclude="$(MSBuildProjectDirectory)\NuspecStaging.proj;$(MSBuildProjectDirectory)\*.nuspec" />
</ItemGroup>

<!-- Copy the .nuspec, other project files in this folder, and requisite lib files into a staging area for packaging. -->
<MakeDir Directories="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(NuspecName).nuspec" DestinationFolder="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="%(ProjectFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\%(ProjectFiles.RecursiveDir)%(ProjectFiles.Filename)%(ProjectFiles.Extension)" />
<Copy SourceFiles="%(LibFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\lib\%(LibFiles.RecursiveDir)%(LibFiles.Filename)%(LibFiles.Extension)" />
</Target>
</Project>
4 changes: 2 additions & 2 deletions Core/Nuspec/Autofac.Web/Autofac.Web.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Autofac.Web</id>
<version>0.0.0.0</version>
<version>$version$</version>
<authors>Autofac Contributors</authors>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand All @@ -13,7 +13,7 @@
<projectUrl>http://autofac.org</projectUrl>
<iconUrl>http://code.google.com/p/autofac/logo</iconUrl>
<dependencies>
<dependency id="Autofac" version="0.0.0.0" />
<dependency id="Autofac" version="$version$" />
</dependencies>
</metadata>
</package>
30 changes: 30 additions & 0 deletions Core/Nuspec/Autofac.Web/NuspecStaging.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Stage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Target Name="Stage">
<Error Text="You must specify the project binary output directory." Condition="'$(BuildBinDirectory)' == ''" />
<Error Text="You must specify the Nuspec staging directory." Condition="'$(StagingDirectory)' == ''" />
<PropertyGroup>
<!-- The name of the .nuspec file being staged, minus extension. -->
<NuspecName>Autofac.Web</NuspecName>
</PropertyGroup>
<ItemGroup>
<!--
Staging goes in build_output\package\nuspec-staging\NuspecName so the
master build script can run NuGet and package it all up.
Select which assemblies from the root build_output folder get included.
Everything else will get staged automatically.
-->
<LibFiles Include="
$(BuildBinDirectory)\**\Autofac.Integration.Web.dll;
$(BuildBinDirectory)\**\Autofac.Integration.Web.xml" />
<ProjectFiles Include="$(MSBuildProjectDirectory)\**\*.*" Exclude="$(MSBuildProjectDirectory)\NuspecStaging.proj;$(MSBuildProjectDirectory)\*.nuspec" />
</ItemGroup>

<!-- Copy the .nuspec, other project files in this folder, and requisite lib files into a staging area for packaging. -->
<MakeDir Directories="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(NuspecName).nuspec" DestinationFolder="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="%(ProjectFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\%(ProjectFiles.RecursiveDir)%(ProjectFiles.Filename)%(ProjectFiles.Extension)" />
<Copy SourceFiles="%(LibFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\lib\%(LibFiles.RecursiveDir)%(LibFiles.Filename)%(LibFiles.Extension)" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion Core/Nuspec/Autofac/Autofac.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Autofac</id>
<version>0.0.0.0</version>
<version>$version$</version>
<authors>Autofac Contributors</authors>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down
32 changes: 32 additions & 0 deletions Core/Nuspec/Autofac/NuspecStaging.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Stage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Target Name="Stage">
<Error Text="You must specify the project binary output directory." Condition="'$(BuildBinDirectory)' == ''" />
<Error Text="You must specify the Nuspec staging directory." Condition="'$(StagingDirectory)' == ''" />
<PropertyGroup>
<!-- The name of the .nuspec file being staged, minus extension. -->
<NuspecName>Autofac</NuspecName>
</PropertyGroup>
<ItemGroup>
<!--
Staging goes in build_output\package\nuspec-staging\NuspecName so the
master build script can run NuGet and package it all up.
Select which assemblies from the root build_output folder get included.
Everything else will get staged automatically.
-->
<LibFiles Include="
$(BuildBinDirectory)\**\Autofac.dll;
$(BuildBinDirectory)\**\Autofac.xml;
$(BuildBinDirectory)\**\Autofac.Configuration.dll;
$(BuildBinDirectory)\**\Autofac.Configuration.xml" />
<ProjectFiles Include="$(MSBuildProjectDirectory)\**\*.*" Exclude="$(MSBuildProjectDirectory)\NuspecStaging.proj;$(MSBuildProjectDirectory)\*.nuspec" />
</ItemGroup>

<!-- Copy the .nuspec, other project files in this folder, and requisite lib files into a staging area for packaging. -->
<MakeDir Directories="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(NuspecName).nuspec" DestinationFolder="$(StagingDirectory)\$(NuspecName)" />
<Copy SourceFiles="%(ProjectFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\%(ProjectFiles.RecursiveDir)%(ProjectFiles.Filename)%(ProjectFiles.Extension)" />
<Copy SourceFiles="%(LibFiles.FullPath)" DestinationFiles="$(StagingDirectory)\$(NuspecName)\lib\%(LibFiles.RecursiveDir)%(LibFiles.Filename)%(LibFiles.Extension)" />
</Target>
</Project>
73 changes: 67 additions & 6 deletions default.proj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
</Target>
<Target Name="Compile">
<MSBuild Projects="%(SolutionFile.FullPath)" Targets="Build" Properties="Configuration=$(BuildConfiguration)" />

<!--
The current build only targets .NET 4.0. It finds all the build output and puts
it in bin\NET40. (Note "NET40" is what NuGet uses as the framework ID for .NET 4.)
When more platforms are targeted, put the appropriate build output into bin\XYZ where
XYZ is the associated NuGet framework identifier. This will allow easier convention-based
NuGet packaging to occur.
-->
<ItemGroup>
<SourceOutputList
Include="
Expand All @@ -68,20 +77,72 @@
%(SourceProject.RootDir)%(SourceProject.Directory)bin\$(BuildConfiguration)\*.config"
Exclude="**\*.vshost.*;**\*.CodeAnalysis.*" />
</ItemGroup>
<Copy SourceFiles="@(SourceOutputList)" DestinationFolder="$(BuildDirectory)\bin" />
<Copy SourceFiles="@(SourceOutputList)" DestinationFolder="$(BuildDirectory)\bin\NET40" />
</Target>
<Target Name="Document">
</Target>
<Target Name="Package">
<PropertyGroup>
<PackageDir>$(BuildDirectory)\package</PackageDir>
<!-- All packages will end up in the package directory. -->
<PackageDirectory>$(BuildDirectory)\package</PackageDirectory>

<!-- Nuspec/NuGet package contents will be staged in a temporary location for building. -->
<StagingDirectory>$(PackageDirectory)\nuspec-staging</StagingDirectory>
</PropertyGroup>
<ItemGroup>
<ExtrasPackageItems Include="$(BuildDirectory)\bin\Autofac.Extras.*" />
<CorePackageItems Include="$(BuildDirectory)\bin\Autofac.*" Exclude="@(ExtrasPackageItems)" />
<!-- One set of Extras and Core items should be created for each target zip file. -->
<NET40ExtrasPackageItems Include="$(BuildDirectory)\bin\NET40\Autofac.Extras.*" />
<NET40CorePackageItems Include="$(BuildDirectory)\bin\NET40\Autofac.*" Exclude="@(NET40ExtrasPackageItems)" />

<!-- The license file gets included with zip files; NuGet packages have a license URL. -->
<LicenseFile Include="$(MSBuildProjectDirectory)\License.txt" />

<!-- Nuspec/NuGet packages get staged using these scripts. -->
<NuspecStagingScripts Include="$(MSBuildProjectDirectory)\**\NuspecStaging.proj" />
</ItemGroup>

<Message Text="Packaging downloadable zip files..." />
<Zip Files="@(NET40CorePackageItems);@(LicenseFile)" ZipFileName="$(PackageDirectory)\Autofac-$(AssemblyVersion)-NET40.zip" Flatten="true" />
<Zip Files="@(NET40ExtrasPackageItems);@(LicenseFile)" ZipFileName="$(PackageDirectory)\Autofac.Extras-$(AssemblyVersion)-NET40.zip" Flatten="true" />

<!--
NuGet packaging is done by convention.
In the folder containing the .nuspec file, add a NuspecStaging.proj file. That project should take in
two variables:
* StagingDirectory = the location where all NuGet package contents are being staged.
* BuildBinDirectory = the location where the compiled binaries are.
The NuspecStaging.proj script should:
* Create a folder under the StagingDirectory where it will stage its package structure.
* Copy the .nuspec file into the folder.
* Create the lib/XYZ folder structure using compiled binaries from BuildBinDirectory.
* Copy any additional files required.
After all Nuspec staging is done, this script will find all .nuspec files in the staging area and:
* Replace any instances of $version$ with the current AssemblyVersion value.
* Run nuget pack to create the .nupkg file.
* Move the .nupkg file to the package folder.
* Remove the temporary staging area.
-->
<Message Text="Staging NuGet package contents..." />
<MSBuild Projects="%(NuspecStagingScripts.FullPath)" Properties="BuildBinDirectory=$(BuildDirectory)\bin;StagingDirectory=$(StagingDirectory)" />
<ItemGroup>
<NuspecFiles Include="$(StagingDirectory)\**\*.nuspec" />
</ItemGroup>
<Message Text="Updating NuGet package version info..." />
<FileUpdate Files="@(NuspecFiles)" Regex="\$version\$" ReplacementText="$(AssemblyVersion)" />
<Message Text="Packaging NuGet packages..." />
<Exec
Command="&quot;$(MSBuildProjectDirectory)\.nuget\nuget.exe&quot; pack %(NuspecFiles.Filename)%(NuspecFiles.Extension)"
WorkingDirectory="%(NuspecFiles.RootDir)%(NuspecFiles.Directory)" />
<ItemGroup>
<NupkgFiles Include="$(StagingDirectory)\**\*.nupkg" />
</ItemGroup>
<Zip Files="@(CorePackageItems)" ZipFileName="$(PackageDir)\Autofac-$(AssemblyVersion).zip" Flatten="true" />
<Zip Files="@(ExtrasPackageItems)" ZipFileName="$(PackageDir)\Autofac.Extras-$(AssemblyVersion).zip" Flatten="true" />
<Move SourceFiles="@(NupkgFiles)" DestinationFolder="$(PackageDirectory)" />
<Message Text="Cleaning NuGet staging..." />
<RemoveDir Directories="$(StagingDirectory)" />
<Message Text="Packaging complete." />
</Target>
<Target Name="Test">
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion go.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
@%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild Autofac.build %*
@%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild default.proj %*

0 comments on commit 6e50867

Please sign in to comment.