Reputation: 1149
Is there a way to create a list of nuget packages that you commonly use, in my case Serilog and then the additional extensions for that.
Is there a way to be able to install all the packages in one go instead of having to search for and install each package one by one?
Upvotes: 0
Views: 195
Reputation: 61
Another solution is this:
Create a .target
file, it is just like a .csproj
file with ItemGroup
's where you can reference your NuGet packages.
Reference the .target
file in another project like this:
<Import Project="../targets/MicrosoftExtensions.target" />
And the example .target
file:
<Project>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.*" />
</ItemGroup>
</Project>
Upvotes: 0
Reputation: 5102
One method is to create a new project, add dependencies, in this case NuGet packages then under the project menu in Visual Studio select Export Template
, select Project template
and follow the prompts.
When naming the project template give the project template a meaningful name.
After completing these steps the template is available under add new projects.
Here is an example of custom templates under VS2019 that are pinned for easy access.
Upvotes: 3