Thanks, Matt, I'm already doing what you talked about, but it seems to me that Nuget does some other things by agreement. Even if I use exclude the same way you said, the document folder is included. I solved the problem by creating a nuspec file with the -a switch (I used my .csproj file). I also had to copy the dll file to a folder outside my solutions folder. Thus, everything worked fine and as expected.
In any case, your answer is correct, but in my scenario it did not work. Not sure if this is by design. Here is my last msbuild file that I use to create the package. Hopefully Nuget will add more switches to the spec command soon, so we donβt have to change the nuspec file so much.
<Project DefaultTargets="NugetPackage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <OutputPathCore>NugetPkgs\$(Configuration)\My.Assembly</OutputPathCore> <NuGetExePath>assets\nuget.exe</NuGetExePath>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/> <Target Name="NugetPackage" DependsOnTargets="PackageClean;BuildNugetPackageMyAssembly">
<Target Name="PackageClean"> <RemoveDir Directories ="NugetPkgs\$(Configuration)" ContinueOnError ="true"/>
<Target Name="BuildNugetPackageMyAssembly"> <MakeDir Directories="$(OutputPathCore)" /> <MakeDir Directories="$(OutputPathCore)\Package" /> <MakeDir Directories="$(OutputPathCore)\lib\net40" /> <MakeDir Directories="$(OutputPathCore)\lib\net20" /> <MakeDir Directories="$(OutputPathCore)\lib\net20-cf" /> <Copy DestinationFolder="$(OutputPathCore)\lib\net40" SourceFiles="Source\My.Assembly\bin\$(Configuration)\My.Assembly.dll" /> <Copy DestinationFolder="$(OutputPathCore)\lib\net20" SourceFiles="VS2008\Source\My.Assembly\bin\$(Configuration)\My.Assembly.dll" /> <Copy DestinationFolder="$(OutputPathCore)\lib\net20-cf" SourceFiles="VS2008\Source\My.Assembly.CF\bin\$(Configuration)\My.Assembly.CF.dll" /> <Copy DestinationFolder="$(OutputPathCore)\content" SourceFiles="CHANGES" /> <Copy SourceFiles="Release Notes.txt" DestinationFiles="$(OutputPathCore)\Readme.txt" /> <Exec Command=""$(NuGetExePath)" spec -a "$(OutputPathCore)\lib\net40\My.Assembly.dll"" /> <XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/licenseUrl" Value="http://someurl" /> <XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/projectUrl" Value="http://someurl" /> <XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/iconUrl" Value="http://somenice.png" /> <XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/tags" Value="My.Assembly" /> <XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/releaseNotes" Value="Review readme.txt for details." /> <ItemGroup> <file Include="Source\My.Assembly\bin\$(Configuration)\My.Assembly.dll"/> <file Include="VS2008\Source\My.Assembly\bin\$(Configuration)\My.Assembly.dll"/> <file Include="$(OutputPathCore)\Readme.txt"/> </ItemGroup> <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="RemoveElement" File="My.Assembly.nuspec" Element="dependencies" XPath="//package/metadata/dependencies" /> <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddElement" File="My.Assembly.nuspec" Key="" Value="" Element="files" XPath="//package" InsertAfterXPath="//package" /> <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddElement" File="My.Assembly.nuspec" Key="src" Value="%(file.Identity)" Element="file" XPath="//package/files" /> <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddAttribute" File="My.Assembly.nuspec" XPath="//package/files/*[1]" Key="target" Value="lib\net40" /> <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddAttribute" File="My.Assembly.nuspec" XPath="//package/files/*[2]" Key="target" Value="lib\net20" /> <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="AddAttribute" File="My.Assembly.nuspec" XPath="//package/files/*[3]" Key="target" Value=""/> <Exec Command=""$(NuGetExePath)" pack My.Assembly.nuspec -OutputDirectory "$(OutputPathCore)\Package" -NoPackageAnalysis" /> <Delete Files ="My.Assembly.nuspec" />
gab
source share