gpt4 book ai didi

c# - .NET 4.7 xunit 测试项目在引用 .NET Standard 1.6 项目时无法构建

转载 作者:行者123 更新时间:2023-11-30 16:43:06 25 4
gpt4 key购买 nike

所以我有一个包含 2 个项目的简单解决方案:

  • .NET Standard 1.6 类库
  • 带有用于测试的 xUnit 的 .NET 4.7 框架类库。

enter image description here

现在,当我尝试在本地构建(在 VS2017 中)时,一切正常。

当我在 Visual Studio Online/Team Services 上构建时,我遇到了很多错误:-

[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)

/\___ 有效! (不是NS1.6版本)

下一个构建相同解决方案的项目...

[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>

我本地的dotnet info版本是

.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

虽然我认为 VSTS 使用的是 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)

最佳答案

我相信我找到了答案 -> 我正在尝试执行以下所有针对 .NET CORE 的步骤:

  1. 恢复
  2. build
  3. 测试
  4. 打包

但这些都是 .NET Core 步骤..并且测试项目是 .NET 4.7 项目。

所以我没有构建测试项目......这就是它出错的原因!该死的。

非常尴尬。

所以 TL;DR;/这里的要点是仔细检查 VSTS 构建步骤并确保它们针对的是正确的项目。

关于c# - .NET 4.7 xunit 测试项目在引用 .NET Standard 1.6 项目时无法构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45638024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com