【问题标题】:How can I build a .csproj that targets .NET 3.5 in VSTS using a Hosted agent?如何使用托管代理在 VSTS 中构建面向 .NET 3.5 的 .csproj?
【发布时间】:2018-01-21 00:59:18
【问题描述】:

理想情况下,我想安装 Visual Studio 2015 Tools for Unity,其中包括 .NET 3.5 子集。但是 .NET 3.5 可以。

当我尝试在 VSTS 中构建项目时,出现以下构建错误:

[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1122,5): Error MSB3644: The reference assemblies for framework ".NETFramework,Version=v3.5,Profile=v3.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

我发现了以下问题:VSTS Hosted Build .Net Framework 4.6.2

但似乎解决方案是在代理运行的机器上安装目标框架。但是我在 VSTS 中使用托管代理。

我假设我可以在这里找到目标包:https://www.microsoft.com/net/download/visual-studio-sdks,但无法在托管代理机器上安装它们。

我可以在不创建自己的代理的情况下完成这项工作吗?

【问题讨论】:

    标签: .net unity3d continuous-integration azure-devops azure-pipelines


    【解决方案1】:

    尝试在 .csproj 文件中添加对 .NET 3.5 引用程序集位置的引用。

    <PropertyGroup>
      <FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
    </PropertyGroup>
    

    参考:Cannot find reference assemblies for .NET 3.5 or lower using core msbuild

    【讨论】:

    • 成功了,谢谢!如果我知道该项目是针对 .Net 3.5 的,我认为我不需要这个条件,对吧?
    • 这个条件只有在你是多目标的时候才是绝对必要的,但如果你不是,保持它也没有什么坏处。
    猜你喜欢
    • 2016-10-24
    • 2017-01-07
    • 1970-01-01
    • 2017-10-28
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多