How can I package a xaml template into a nuget package for other developers to reuse?

Viewed 136

I have created a nuget out of some reusable code and frameworks that I have created for other developers to leverage and develop solutions faster. The nuget is hosted on our private nuget feed. Our application is a WPF application with clickonce deployment strategy. Now I would like to give the developers the mainwindow.xaml that I use as a template so that I can create a standardization. Is there any way I can package the mainwindow.xaml as a reusable template in the same nuget package that I have hosted in my private feed or atleast can I create a new nuget and host it for the same purpose?

1 Answers

You can place the MainWindow.xaml and MainWindow.cs files in the content directory of your NuGet package, and create an Init.ps1 PowerShell script to move those files into the project.

The script’s parameters are:

param($installPath, $toolsPath, $package, $project)

There is some good information about adding files to the content directory at https://docs.microsoft.com/en-us/nuget/reference/nuspec

Related