Convert .csproj using nuget package

I know that you can convert source files and configuration files using the special Nuget package. Unfortunately, I cannot find anywhere else how to add or modify the .csproj file. Is it possible?

+5
source share
1 answer

The only file changes that are directly supported in NuGet without resorting to using PowerShell:

You can add files from the NuGet package to the project, but they will overwrite existing files. Added files can also be converted if they are .pp files.

Note that there is a transition from PowerShell scripts to NuGet 3, so you may need to see if you can get away from using PowerShell. Other alternatives are custom MSBuild.props and .targets files, which you can include in your NuGet package, which can be used to indirectly modify project files. Basically, you can add whatever you want to an existing project in your own MSBuild.targets file, as it is imported into the project.

PowerShell scripts can be used to add or modify .csproj. There are several examples of NuGet packages that do this, such as the older Bcl Build NuGet package , which adds an import element to the project. Note that adding imports is directly supported in the latest NuGet.

Converting existing code files using PowerShell is more difficult, but you can modify code files using the Visual Studio object model .

+6
source

Source: https://habr.com/ru/post/1241512/


All Articles