TeamCity NuGet package build for different .NET Frameworks

╄→гoц情女王★ 提交于 2019-12-05 14:05:44

Ok I ended up solving this through trial and error and learning about NuSpec. Note, I didn't find a way to do this using purely TeamCity settings but this is equally good.

I was correct that you need extra build steps to build the assemblies in the solution/project level build configurations and point each Configuration at Release-NetX.

EDIT I've found it's actually best in the above to point the NetX build steps at the .csproj rather than the .sln. That way you don't need the build configurations at a solution level, as long as they exist in the .csproj then it will all build fine.

Once this is done, TC will then be building all versions into their respective bin\Release-NetX directories.

Next was to add a .nuspec file to the root directory of the solution project to build the NuGet for.

<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <id>Foo.Bar.Package</id>
    <version>1.0.23</version>
    <authors>FooBar Industries</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>FooBar Industries package</description>
  </metadata>
  <files>
    <file src="bin\Release\*.dll" target="lib\net462" />
    <file src="bin\Release-Net46\*.dll" target="lib\net46" />
    <file src="bin\Release-Net45\*.dll" target="lib\net45" />
    <file src="bin\Release-Net4\*.dll" target="lib\net40" />
  </files>
</package>

Next is to alter the NuGet Pack TeamCity Build Step and in Specification files section and point this to your .nuspec file. There's a checkbox for Prefer project files to .nuspec. It worked for my just by unchecking this and I didn't even need to point to .nuspec file.

Then on triggering a build, all versions are outputted and are then available to use without upgrading all projects that reference this package.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!