TGl*_*zer 4 templates .net-core
我正在尝试创建一个dotnet new
包含我的团队使用的“默认”.editorconfig 和 .gitconfig 的简单模板。
不幸的是,.files 不会被包含在dotnet pack
.
这是我的 .csproj 的一部分:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageType>Template</PackageType>
<TargetFramework>net6.0</TargetFramework>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
</PropertyGroup>
<PropertyGroup>
<Description>dotnet new templates</Description>
<PackageTags>template dotnet console</PackageTags>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="**\*" />
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**;templates\**\.vs\**" />
<Content Include="templates\SolutionTemplate\.editorconfig;templates\SolutionTemplate\.gitignore" Pack="true" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
尽管已明确添加,但 .editorconfig 和 .gitignore 将被忽略。有人有这方面的经验吗?
dot*_*arj 11
有多种解决方案,最简单的是将NoDefaultExcludes(“防止默认排除 NuGet 包文件以及以点开头的文件和文件夹,例如 .svn 和 .gitignore。”)添加到您的 csproj,如下所示:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<NoDefaultExcludes>true</NoDefaultExcludes>
...
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
使用此选项将包含 .editorconfig 和 .gitignore 文件,但也可能包含以点开头的其他文件或包文件。
我使用另一个选项来命名模板存储库中的文件 editorconfig 和 gitignore,并将 .template.config/template.json (在模板安装期间执行)中的文件重命名为 .editorconfig 和 .gitignore,如下所示:
{
...
"sources": [
{
"modifiers": [
{
"rename": {
"editorconfig": ".editorconfig",
"gitignore": ".gitignore"
}
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
707 次 |
最近记录: |