umbraco / UmbPack

13 stars 13 forks source link

Add MSBuild task #64

Open ronaldbarendse opened 2 years ago

ronaldbarendse commented 2 years ago

Creating a NuGet package using the SDK/csproj properties is now really easy by using dotnet pack. This uses the Pack MSBuild target underneath and we can already piggyback on this by adding the following target to your csproj:

<Target Name="UmbPack" AfterTargets="Pack">
    <Exec Command="umbpack pack package.xml -v $(Version) -o $(PackageOutputPath) -p Configuration=$(Configuration)" />
</Target>

This does however also require UmbPack to be installed as global dotnet tool. It's possible to write a native MSBuild task that can be included into your project by simply installing a single NuGet package, which removes this requirement, but can also automatically add the above target to your project.

We can also re-use a lot of the existing package properties to automatically populate the package.xml and introduce extra input properties to specify the path to the XML file, e.g.:

We can start by first requiring the path to the package.xml to be set, but eventually might be able to auto-generate it.