3
votes

I'm hoping someone has some advice on the best way to use Teamcity to build and publish a solution that has both .NET Core/standard 2.0 projects and .NET framework 4.6.x projects in it.

Currently, I can build the project, run tests, but I can't figure out a way to publish it via the dotnet-cli. We have a relatively large solution, approximately 75 projects in .NET core/standard and 5 or some framework projects. Running dotnet publish on our solution results in the following error on the .NET framework projects:

error: C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(3861,5): error MSB4062: The "Microsoft.Build.Tasks.ResolveManifestFiles" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

It would be ideal if the cli could attempt to ignore publishing the .NET Framework projects, but it doesn't seem to be possible. I'm thinking about writing a powershell script to check all csproj files in our solution for an appropriate TargetFramework value (i.e netstandard2.0/netcoreapp2.0), and publish them individually, but maybe someone knows a better way?

1
Are all your projects using the new csproj file structure? The dotnet CLI only works with that.nvoigt
Thank you, this fixed the problem. Is there a way to create a new framework projects with the new csproj format in Visual studio? I followed these instructions about replacing the csproj content: hanskindberg.wordpress.com/2017/04/18/…Benedict

1 Answers

0
votes

If anyone is facing the same issue, you need to restructure your csproj file as suggested by @nvoigt.

You can follow the steps as described in the post Old csproj to new csproj

You can start clearing out your csproj file and start with below format.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net462</TargetFramework> // if your target is 4.6.2
  </PropertyGroup>
</Project>

  

And now you can add remaining of your dependency like below.

   ...
      <ItemGroup>
        <PackageReference Include="Dapper" Version="2.0.4" />
        <PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.1" />
        <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
        <PackageReference Include="Microsoft.Azure.KeyVault" Version="2.0.6" />
        <PackageReference Include="NLog" Version="4.7.5" />
        <PackageReference Include="NLog.Extensions.Logging" Version="1.6.5" />
      </ItemGroup>
   ...

you can find more details on the post.