Pure.Krome
Pure.Krome

Reputation: 86937

.NET 4.7 xunit test project fails to build when referencing a .NET Standard 1.6 project

So I have a simple solution with 2x projects:

enter image description here

Now when I try and build (in VS2017) locally, all is ok.

When I build on Visual Studio Online/Team Services, I get heaps of errors:-

[command]"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\src\Hornet.Services\Hornet.Services.csproj -c release /p:Version=1.0.0
Microsoft(R) Build Engine version 15.1.1012.6693
Copyright(C) Microsoft Corporation.All rights reserved.

Hornet.Services -> d:\a\1\s\src\Hornet.Services\bin\release\netstandard1.6\Hornet.Services.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

/\___ Works! (Not the NS1.6 version)

next project to build in the same solution ...

[command]"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\tests\Hornet.Services.Tests\Hornet.Services.Tests.csproj -c release /p:Version= 1.0.0
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation.All rights reserved.

Hornet.Services -> d:\a\1\s\src\Hornet.Services\bin\release\netstandard1.6\Hornet.Services.dll
C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference.Could not locate the assembly "Castle.Core, Version=4.1.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL". Check to make sure the assembly exists on disk.If this reference is required by your code, you may get compilation errors. [d:\a\1\s\tests\Hornet.Services.Tests\Hornet.Services.Tests.csproj]
C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "FizzWare.NBuilder, Version=5.0.0.138, Culture=neutral, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\1\s\tests\Hornet.Services.Tests\Hornet.Services.Tests.csproj]
C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "FluentValidation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\1\s\tests\Hornet.Services.Tests\Hornet.Services.Tests.csproj]
C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Google.Apis, Version=1.28.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\1\s\tests\Hornet.Services.Tests\Hornet.Services.Tests.csproj]
C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Google.Apis.Core, Version=1.28.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\1\s\tests\Hornet.Services.Tests\Hornet.Services.Tests.csproj]
C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Google.Apis.PlatformServices, Version=1.28.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\1\s\tests\Hornet.Services.Tests\Hornet.Services.Tests.csproj]
C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Google.Apis.QPXExpress.v1, Version=1.28.0.554, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\1\s\tests\Hornet.Services.Tests\Hornet.Services.Tests.csproj]

.. <lots more snipped>

My local version of dotnet info is

.NET Command Line Tools (1.0.4)

Product Information:
 Version:            1.0.4
 Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.4

while i think VSTS is using 1.0.2

==============================================================================
 Task         : .NET Core
 Description  : Build, test and publish using dotnet core command-line.
 Version      : 1.0.2
 Author       : Microsoft Corporation
 Help         : [More Information] (https://go.microsoft.com/fwlink/?linkid=832194)

Upvotes: 3

Views: 1054

Answers (1)

Pure.Krome
Pure.Krome

Reputation: 86937

I believe I found my answer -> I was trying to do the following steps all targeting .NET CORE :

  1. Restore
  2. Build
  3. Test
  4. Pack

but these are all .NET Core steps .. and the test project is a .NET 4.7 project.

So I didn't build the test project ... which was why it was erroring! Damn it.

Much embarrassment.

So the TL;DR; / Takeaway here is to double check the VSTS Build Steps and make sure they are targeting the correct items.

Upvotes: 2

Related Questions