内容目录
背景:
When debugging tests, it's necessary to use NSwag.AspNetCore to provide swagger services, but it's not needed for formal release deployment. The NSwag.AspNetCore library file reaches 6MB. This can be handled in the project file using the condition Condition="'$(Configuration)'=='DEBUG'"
.
示例:
<PackageReference Condition="'$(Configuration)'=='DEBUG'" Include="NSwag.AspNetCore" Version="13.2.0" />
大佬的示例
<Project>
<PropertyGroup>
<VersionMajor>1</VersionMajor>
<VersionMinor>8</VersionMinor>
<VersionPatch>2</VersionPatch>
<VersionRevision>0</VersionRevision>
<VersionPrefix Condition="'$(VersionRevision)'=='0'">$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
<VersionPrefix Condition="'$(VersionRevision)'!='0'">$(VersionMajor).$(VersionMinor).$(VersionPatch).$(VersionRevision)</VersionPrefix>
<VersionSuffix Condition="'$(Configuration)'=='DEBUG'">preview-$([System.DateTime]::Now.ToString("yyyyMMdd-HHmmss"))</VersionSuffix>
<InformationalVersion>$(PackageVersion)</InformationalVersion>
</PropertyGroup>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/WeihanLi/WeihanLi.Npoi</RepositoryUrl>
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Authors>WeihanLi</Authors>
<Copyright>Copyright 2017-2019 (c) WeihanLi</Copyright>
<NoWarn>$(NoWarn);NU5048;</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Condition="'$(OS)' == 'Windows_NT'" Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Condition="'$(OS)' != 'Windows_NT'" Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" PrivateAssets="All" />
</ItemGroup>
</Project>
地址:
https://github.com/WeihanLi/WeihanLi.Npoi/blob/dev/Directory.Build.props
文章评论