[英]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.