如何创建自定义 nuget 包,其中定义了新的构建配置“TestConfiguration”并将添加到项目和解决方案文件中。
在解决方案文件中,我想添加以下内容:
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
TestConfiguration|Any CPU = TestConfiguration|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4C75633E-8F7C-4715-8F9E-0003A3F11FF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C75633E-8F7C-4715-8F9E-0003A3F11FF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C75633E-8F7C-4715-8F9E-0003A3F11FF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C75633E-8F7C-4715-8F9E-0003A3F11FF8}.Release|Any CPU.Build.0 = Release|Any CPU
{4C75633E-8F7C-4715-8F9E-0003A3F11FF8}.TestConfiguration|Any CPU.ActiveCfg = TestConfiguration|Any CPU
{4C75633E-8F7C-4715-8F9E-0003A3F11FF8}.TestConfiguration|Any CPU.Build.0 = TestConfiguration|Any CPU
EndGlobalSection
在项目文件中应添加以下内容(这已经与下面的 .nupkg 一起使用):
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'TestConfiguration|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\TestConfiguration\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
我的客户 NugetPackage "MyPackage.nupkg" 有以下内容:
- 构建(文件夹)
- MyPackage.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'TestConfiguration|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\TestConfiguration\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
</Project>