简体   繁体   English

Azure Devops - 针对解决方案中的多个 .NET 框架

[英]Azure Devops - Targeting Multiple .NET frameworks in solution

I have setup Azure pipeline which build several projects and solutions with different .NET frameworks.我已经设置了 Azure 管道,它使用不同的 .NET 框架构建了多个项目和解决方案。 Used frameworks: .NET Standard 2.1, .NET 4.7.2, .NET5, .NET Core 3.1.使用的框架:.NET Standard 2.1、.NET 4.7.2、.NET5、.NET Core 3.1。 I use pool windows-2019 and everything works fine.我使用池windows-2019 ,一切正常。

Now, I have to build new project which targets .NET 6 and has to be build first in pipeline.现在,我必须构建以 .NET 6 为目标的新项目,并且必须首先在管道中构建。 Because pool windows-2019 doesn't have installed .NET 6, I have to install it using UseDotNet task.因为池 windows-2019 没有安装 .NET 6,所以我必须使用UseDotNet任务安装它。 But once I install .NET 6, the rest of projects build fail.但是一旦我安装了 .NET 6,其余的项目构建就会失败。

I know that older framework can be specified again using UseDotNet task, but I have problem because one solution (Solution 3 in yaml snippet) include projects using .NET 5 and .NET Core 3.1.我知道可以使用UseDotNet任务再次指定较旧的框架,但我遇到了问题,因为一个解决方案(yaml 片段中的解决方案 3)包括使用 .NET 5 和 .NET Core 3.1 的项目。 So when I specify .NET 5 with UseDotNet task, solution build fails because .Net Core 3.1 is missing or viceversa.因此,当我使用UseDotNet任务指定 .NET 5 时,解决方案构建失败,因为缺少 .Net Core 3.1,反之亦然。

Is it possible to specify two frameworks to be used before solution build?是否可以在解决方案构建之前指定要使用的两个框架? Or how this situation should be handled?或者这种情况应该如何处理?

Snippet:片段:

pool:
      vmImage: 'windows-2019'

- task: UseDotNet@2
  displayName: 'Use .NET 6 sdk'
  inputs:
    version: 6.0.x
    includePreviewVersions: true

#Project Uses only .Net 6
- task: DotNetCoreCLI@2
  displayName: 'Build ProjectUsingNet6'
  inputs:
    command: 'build'
    projects: '**\ProjectUsingNet6.sln'

#Solution uses only .NET 3.1
- task: UseDotNet@2
  displayName: 'Use .Net Core 3.1'
  inputs:
    version: '3.1.x'

- task: VSBuild@1
  displayName: ProjectUsingNet31
  inputs:
    solution: '**\SolutionTargetingNet31.sln'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    
#Projects in solution tagerting .NET Standard 2.1, .NET 4.7.2, .NET 5, .Net Core 3.1 which fails
- task: VSBuild@1
  displayName: Solution 3
  inputs:
    solution: '**\Solution3.sln'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

Azure Devops - Targeting Multiple .NET frameworks in solution Azure Devops - 针对解决方案中的多个 .NET 框架

Agree with GeralexGR.同意 GeralexGR。 When you have multiple .NET frameworks in solution, you could use the stage for each framework, especially if your .NET frameworks are not backward compatible.当您的解决方案中有多个 .NET 框架时,您可以为每个框架使用该阶段,尤其是当您的 .NET 框架不向后兼容时。

stages:
- stage: .NET 6 sdk
  jobs:
  - job:
    ...

- stage: .NET 5 sdk
  jobs:
  - job:
    ...

- stage: .NET 3.1 sdk
  jobs:
  - job:
    ...

You could check the Add stages, dependencies, & conditions for some more details.您可以检查添加阶段、依赖项和条件以获取更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure DevOps:解决多个.Net框架时测试失败 - Azure DevOps: tests failing when addressing multiple .Net frameworks 在单个二进制文件中定位多个.NET框架? - Targeting multiple .NET frameworks in a single binary? 针对多个框架 - Targeting multiple frameworks 使用Cake脚本定位多个框架 - Targeting multiple frameworks with Cake script .NET 针对 VS2017 中的多个框架。 如何获取 IDE 以针对特定的预处理器指令? - .NET targeting multiple frameworks in VS2017. How to get IDE to target specific preprocessor directive? 有没有办法在 Azure Devops 的一个解决方案中引用多个项目? - Is there a way to have multiple projects referenced in one solution with Azure Devops? 使用.NET Core定位多个框架的编译器指令 - Compiler directives for targeting several frameworks using .NET Core Newtonsoft.Json许多针对不同.net框架的项目 - Newtonsoft.Json many projects targeting different .net frameworks Azure DevOps - 无法从 ASP.NET 构建设置中的默认解决方案文件设置取消链接 - Azure DevOps - not able to unlink from default solution file setting in ASP.NET build settings 我可以在 Azure DevOps 中使用 dotnet publish 命令发布 .net 框架 4.7.1 解决方案吗 - Can I publish .net framework 4.7.1 solution with dotnet publish command in Azure DevOps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM