首页 > 解决方案 > 在 VSTS 构建代理中构建解决方案时出现错误 CS0246

问题描述

我在 Visual Studio 2017 中创建了一个项目。它在本地完美构建,但是在尝试使用 VSTS 构建代理构建时,它给出以下警告 -

[warning]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "StackExchange.Redis, Version=1.2.6.0, 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.

然后低于错误 -

    [error]..\Utils\RedisService.cs(4,7): Error CS0246: The type or namespace name 'StackExchange' could not be found (are you missing a using directive or an assembly reference?) 
2018-07-18T13:03:08.3934570Z Utils\RedisService.cs(4,7): error CS0246: The type or namespace name 'StackExchange' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\myProject.csproj]
2018-07-18T13:03:08.3938262Z ##[error]..\Utils\RedisService.cs(18,16): Error CS0246: The type or namespace name 'IDatabase' could not be found (are you missing a using directive or an assembly reference?)
2018-07-18T13:03:08.3939130Z Utils\RedisService.cs(18,16): error CS0246: The type or namespace name 'IDatabase' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\myProject.csproj]

目标框架是 4.7 ,并在构建任务中使用 nuget restore 版本 4.4.1 。

请提出一些解决方案,我检查了多个博客但没有得到帮助。

编辑 1 - 构建定义屏幕截图

标签: c#msbuildazure-pipelinesazure-pipelines-build-task.net-4.7

解决方案


推荐阅读