Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
msbuild targets file for NuGet packaging & publish to local repos
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup >
<AvailableItemName Include="NuGetSpec">
<Visible>false</Visible>
</AvailableItemName>
</ItemGroup>
<PropertyGroup>
<NuGetRepository Condition="'$(NuGetRepository)' == ''">\\nugetrepos.local\NuGetRepos</NuGetRepository>
</PropertyGroup>
<Target Name="NuGetPackage"
AfterTargets="Build"
Inputs="@(NuGetSpec);@(FileWrites)"
Outputs="%(NuGetSpec.Identity).pkglog" >
<Exec Command="..\.nuget\Nuget.exe pack -OutputDirectory $(OutputPath) "
LogStandardErrorAsError="true" />
<ItemGroup>
<NuGetPackages Include="$(OutputPath)*.nupkg" />
</ItemGroup>
<WriteLinesToFile File="%(NuGetSpec.Identity).pkglog" Lines="@(NuGetPackages)"/>
</Target>
<Target Name="PushNuGetPackage" AfterTargets="NuGetPackage" >
<Copy SkipUnchangedFiles="true"
SourceFiles="@(NuGetPackages)"
DestinationFolder="$(NuGetRepository)" />
<Message Text="@(NuGetPackages) was copied to $(NuGetRepository)" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment