Skip to content

Commit

Permalink
Add IsTrimmable option to NuGet package
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanSaeed committed Nov 12, 2021
1 parent bdd46b8 commit 49e100b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Docs/NuGet.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The NuGet package project template uses `dotnet new` to enable you to turn featu
- **AllEnabledByDefault** - Enables all code analysis rules.
- **AllDisabledByDefault** - Disables all code analysis rules.
- **ImplicitUsings** - Enables implicit using statements in all projects which adds some default System.* namespaces.
- **IsTrimmable** - Enables the library for trimming which reduces the size of applications by removing unused code.
- **TreatWarningsAsErrors** (Default=On) - Treat warnings as errors.
- **StyleCop** (Default=On) - Adds and enforces StyleCop analysers.
- **Tests** (Default=On) - Adds a unit test project.
Expand Down
3 changes: 3 additions & 0 deletions Source/NuGetTemplate/.template.config/dotnetcli.host.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
"ImplicitUsings": {
"longName": "implicit-usings"
},
"IsTrimmable": {
"longName": "trimmable"
},
"TreatWarningsAsErrors": {
"longName": "treat-warnings-as-errors"
},
Expand Down
4 changes: 4 additions & 0 deletions Source/NuGetTemplate/.template.config/ide.host.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
"id": "ImplicitUsings",
"isVisible": true
},
{
"id": "IsTrimmable",
"isVisible": true
},
{
"id": "TreatWarningsAsErrors",
"isVisible": true
Expand Down
7 changes: 7 additions & 0 deletions Source/NuGetTemplate/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@
"displayName": "Implicit Usings",
"description": "Enables implicit using statements in all projects which adds some default System.* namespaces."
},
"IsTrimmable": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"displayName": "Is Trimmable",
"description": "Enables the library for trimming which reduces the size of applications by removing unused code."
},
"TreatWarningsAsErrors": {
"type": "parameter",
"datatype": "bool",
Expand Down
2 changes: 2 additions & 0 deletions Source/NuGetTemplate/Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<PropertyGroup>
<!-- Workaround to build this project: https://github.com/dotnet/templating/issues/1438 -->
<GitHub>true</GitHub>
<IsTrimmable>true</IsTrimmable>
<Sign>true</Sign>
</PropertyGroup>
<!--#endif-->

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup Label="Build">
<IsTrimmable Condition="'$(IsTrimmable)' == 'true'">true</IsTrimmable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
Expand Down

0 comments on commit 49e100b

Please sign in to comment.