Framework project referencting multi targeted .NET Core build not restoring nuget packages.

I have a solution with a .NET 4.6.1 project. This project references a multi targeted .NET Core netstandard2_0 library.

The core library has nuget dependencies for AWSK that create a compile error for missing references when run through team city using the VS 2017 builder. Inside visual studio it works fine on the build box (IE it pulls down the nuget packages and builds them for both the framework and core projects.). However running the build in Team City I get error CS0246: The type or namespace name 'Amazon' could not be found (are you missing a using directive or an assembly reference? Trying to get around it, I tried adding a pre-step to build the projects with dotnet build which succeeds for the core projects. However the normal build step for the framework still produced the compilation error for the missing amazon libraries.

Trying to get around it, I found raw "msbuild /t:Restore /t:Build" from the command line in the work folder also works just fine, both locally on the build server. So I switched to the msbuild runner int Team City and it failed with [ReportAssetsLogMessages] C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(327, 5): Assets file 'C:\TeamCity\buildAgent\work\704f4f6419fbe427\Gadget.Shared.Library.Core\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

So I added back the manual dotnet restore step which brought me back to the same compilation error error CS0246: The type or namespace name 'Amazon' could not be found (are you missing a using directive or an assembly reference?. Full circle.

When digging through the logs I found the command being produced by Team City is using Build targets: TeamCity_Generated_Build;Restore;Build Is there a way to force TeamCity to NOT replace the standard build target, or at least let the restore go first?

3
2 comments
Avatar
Permanently deleted user

We're experiencing the same issues. We have any number of unit test libraries in net461 referencing our DotNetStandard solution, that could be unit tests, integration tests, smoke tests, feature tests or regression tests, and we can't templatize all of them, so this is really causing a burden on us as well.

0

We have few options here:

- `msbuild` runner with targets `restore;build` unfortunately msbuild runner does not support `/r`, but `restore` is actually its analog
- 2 build steps: `NuGet Installer` runner + `msbuild` runner
- `dotnet CLI` runner if targeting frameworks are net40+

0

Please sign in to leave a comment.