.Net Core 模板项目笔记/Tips on .Net Core template project

https://github.com/dotnet/templating/wiki/Runnable-Project-Templates

现在.net项目的csproj文件里不需要写ProjectGuid了,在.sln文件里会有ProjectGuid。

但是在安装SonarQube的低版本的时候(好像7.6之后不需要了,但是7.6开发版需要花钱) 需要csproj文件里有ProjectGuid。

但是现在又是个Template项目,ProjectGuid是不能直接拷贝的。怎么办?

方法是:

在template.json文件放上这样的内容:

guid的值就是csproj文件里的ProjectGuid。
这样在以这个Template为基础创建新项目的时候,就会自动把这个值用新的值覆盖
而且,如果有多个地方出现同样的串,生成的新项目也会用同样的值覆盖。

想测试生成的Template是否修改正确?
1. 在wrapper的项目上右击选Pack

就会在bin/Debug文件夹生成一个.nupkg的文件。
2.
Create a template using above nuget package file in powershell:  
dotnet new -i C:\Users\Jessica.Zhang\source\repos\***\bin\Debug\*.nupkg  
需要用自己的项目的情况覆盖*的地方
It will create a template and can be seen in Visual Studio when create a new project:
 

 3. Create a new project based on above template in Visual Studio. 

The ProjectGuid in *.csproj has been changed.

Check the sln file, the ProjectGuids are coincident with the ones in csproj files. 

 
posted @ 2021-07-01 21:01  Jessica_Zhang  阅读(91)  评论(0)    收藏  举报