Skip to content

Commit ea7d55d

Browse files
authored
Add NoDefaultExcludes to the templatepack.csproj (#28747)
The `NoDefaultExcludes` removes the default behaviors of `dotnet pack` that doesn't pack all the files and folders that starts with a `.`, such as `.gitignore`. In the case of the template, we would probably want those files to be available if they have been defined in the template.
1 parent b13eae1 commit ea7d55d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/core/tutorials/cli-templates-create-template-package.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Next, open the _templatepack.csproj_ file in your favorite editor and replace th
8080
<IncludeBuildOutput>false</IncludeBuildOutput>
8181
<ContentTargetFolders>content</ContentTargetFolders>
8282
<NoWarn>$(NoWarn);NU5128</NoWarn>
83+
<NoDefaultExcludes>true</NoDefaultExcludes>
8384
</PropertyGroup>
8485

8586
<ItemGroup>
@@ -99,7 +100,9 @@ The `<TargetFramework>` setting must be set so that MSBuild will run properly wh
99100

100101
The next three settings have to do with configuring the project correctly to include the templates in the appropriate folder in the NuGet pack when it's created.
101102

102-
The last setting suppresses a warning message that doesn't apply to template package projects.
103+
The `<NoWarn>` setting suppresses a warning message that doesn't apply to template package projects.
104+
105+
The last `<NoDefaultExcludes>` settings removes the default behavior of NuGet packages to ignore files and folders starting with a `.` (like `.gitignore`) because they should be part of the template.
103106

104107
The `<ItemGroup>` contains two settings. First, the `<Content>` setting includes everything in the _templates_ folder as content. It's also set to exclude any _bin_ folder or _obj_ folder to prevent any compiled code (if you tested and compiled your templates) from being included. Second, the `<Compile>` setting excludes all code files from compiling no matter where they're located. This setting prevents the project being used to create a template package from trying to compile the code in the _templates_ folder hierarchy.
105108

0 commit comments

Comments
 (0)