문제 설명
Azure Devops에서 msbuild를 사용하여 릴리스 및 디버그 구성 모두로 너겟 파일을 만드는 방법 (How to create a nuget file with both the Release and Debug configurations using msbuild in Azure Devops)
내 dll의 릴리스 버전과 디버그 버전을 모두 포함하는 너겟 파일을 만들어야 합니다. MSBuild 작업을 사용하여 Azure Devops에서 이 작업을 수행할 수 있어야 합니다.
새 packagereference 및 projectreference를 사용하면 작동하지 않는 NuGet 작업의 버그로 인해 MSBuild를 사용하고 있습니다. 종속성 정보를 올바르게.
저는 디버그와 릴리스에서 두 가지 빌드를 시도한 다음 릴리스에서 팩을 하도록 했습니다. 이것은 여전히 하나의 파일 만 제공했습니다. 또한 nuspec 파일을 사용하여 두 파일을 모두 가져오도록 지시했지만 여전히 패키지에 하나의 파일만 있었습니다.
참조 솔루션
방법 1:
How to create a nuget file with both the Release and Debug configurations using msbuild in Azure Devops
I am afraid you could not create a nuget file with both the Release and Debug configurations using msbuild at this moment.
That because NuGet package will normally hold just a single set of assemblies for a particular target framework. It is not really designed to ship a debug and release version.
If we use nuget, we could use a custom MSBuild .targets
file in the .nuspec
that has its own references and configuration information:
Check this thread for some more details.
But, if you want use the MSBuild, we could not specify the dlls file driectly, we have to create two packages for debug
and release
, then we add a custom MSBuild .targets
file in the project file with the properties <Pack>true</Pack>
and <PackagePath>build\</PackagePath>
, like following:
<ItemGroup>
<None Include="build\*.targets" Pack="True" PackagePath="build\" />
</ItemGroup>
In this case, the .targets
file will be packed in the build folder, which will imported into the nuget installation project:
Check this thread for some more details.
Besides, in the .targets
file, you could use a Choose/When
to select the PackageReference
for debug
and release
:
<Choose>
<When Condition=" '$(Configuration)'=='debug' ">
<ItemGroup>
<PackageReference Include="MyRefDebug">
<Version>1.0</Version>
</PackageReference>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="MyRefRelease">
<Version>2.0</Version>
</PackageReference>
</ItemGroup>
</Otherwise>
</Choose>
Check the github ticket for some more details.
Hope this helps.