【问题标题】:How to Specify .NET Framework Version in YAML Pipeline?如何在 YAML 管道中指定 .NET Framework 版本?
【发布时间】:2020-10-21 12:01:35
【问题描述】:

我对 YAML 非常陌生——我正在尝试使用构建 B 中已发布的工件 DLL 更新插件库(请参阅下面的 YAML),但是我不断收到以下错误:

如何在 YAML 中指定 .NET Framework,使其不尝试使用旧版本?我需要它来使用 4.6.2。我浏览了每个 Microsoft Doc,发现您可以指定它运行测试,但尝试找到如何为构建设置它的运气为零。

澄清一下,下面的 YAML 成功运行,我可以下载 DLL,但更新插件注册时会导致错误。

'''

trigger: none

pool:
  vmImage: 'windows-latest'

steps:

- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: 'A/A.sln'

#Build the solutions
- task: VSBuild@1
  displayName: 'Build A Library'
  inputs:
    solution: 'A/A.sln'
    msbuildArgs: '/p:DeployOnBuild=true 
                  /p:WebPublishMethod=Package 
                  /p:PackageAsSingleFile=true 
                  /p:SkipInvalidConfigurations=true 
                  /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" 
                  /p:DeployIisAppPath="Default Web Site"'
    platform: 'Any CPU'
    configuration: 'Release'

- task: VSBuild@1
  displayName: 'Build B Library'
  inputs:
    solution: 'B/B/B.sln'
    msbuildArgs: '/p:DeployOnBuild=true 
                  /p:WebPublishMethod=Package 
                  /p:PackageAsSingleFile=true 
                  /p:SkipInvalidConfigurations=true 
                  /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" 
                  /p:DeployIisAppPath="Default Web Site"'
    platform: 'Any CPU'
    configuration: 'Release'

- publish: $(System.DefaultWorkingDirectory)/B/B/B/bin/Release/B.dll
  artifact: BDll

'''

【问题讨论】:

    标签: yaml azure-pipelines azure-pipelines-yaml


    【解决方案1】:

    从问题中的linked doc 来看,问题的原因是 在 .NET Framework 3.5 版及更早版本中,如果您从远程位置加载程序集,则程序集将部分信任运行取决于加载它的区域的授权集。如果您尝试在 .NET Framework 版本 4 和更高版本中运行该程序集,则会引发异常。

    您可以在 config 文件中添加这一行:

    <configuration> <runtime> <loadFromRemoteSources enabled="true"/> </runtime> </configuration>
    

    如果你想针对 .NET Framework 4.6.2,你可以在 YMALmsbuildArgs 中添加这一行:

    /p:TargetFrameworkVersion="v4.6.2"
    

    如果不添加此行,它将在构建时使用默认的旧 .NET Framework。

    【讨论】:

      猜你喜欢
      • 2020-05-28
      • 1970-01-01
      • 2021-06-19
      • 1970-01-01
      • 1970-01-01
      • 2022-07-20
      • 2019-09-22
      • 1970-01-01
      • 2011-03-28
      相关资源
      最近更新 更多