gpt4 book ai didi

c# - 我可以在 Azure DevOps 中使用 dotnetpublish 命令发布 .net Framework 4.7.1 解决方案吗

转载 作者:行者123 更新时间:2023-12-03 00:36:28 25 4
gpt4 key购买 nike

我有一个目标框架为 4.7.1 的解决方案。我已在本地安装了 dotnet core sdks,并且能够发出构建、发布命令。

我的项目文件如下所示,其中有许多对 dotnet core dll 的引用

<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.3.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.4.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0">

我在尝试使用特定的 .net sdk 构建此解决方案时,Azure DevOps yaml 中出现错误。

    - task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '2.x'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
workingDirectory: '$(solution)'

错误内容为尝试执行进程“C:\hostedtoolcache\windows\dotnet\dotnet.exe”时出错。这可能表明该进程未能启动。错误:生成 C:\hostedtoolcache\windows\dotnet\dotnet.exe

更重要的是,我不确定应该使用哪个 dotnet core 版本来构建这个项目?

在本地,我有 dotnet 5 sdk,并且能够使用 dotnet 发布命令成功发布。我应该在 DevOps 中使用哪些命令来构建 net471 项目?

谢谢,AK

最佳答案

.NET Core is different as compared to .NET Framework .

此外,如果您想为 .NET Framework 项目创建管道,则不能使用 .NET Core 任务。您的 PipelineYAML 文件应如下所示:

# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4

trigger:
- master

pool:
vmImage: 'VS2017-Win2016'

variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'

- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
inputs:
PathtoPublish: $(build.artifactstagingdirectory)
ArtifactName: 'PublishBuildArtifacts'


请参阅此的分步教程 here .

关于c# - 我可以在 Azure DevOps 中使用 dotnetpublish 命令发布 .net Framework 4.7.1 解决方案吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65391555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com