Azure devops Azure devops构建管道似乎两次恢复nuget软件包
我有一个构建管道,其中我有一个使用NuGetCommand的Nuget恢复步骤,该步骤运行良好 但是执行构建的下一步在缺少nuget包的情况下失败 构建步骤似乎试图第二次恢复nuget包,但这不起作用 (它没有这样做的凭据) 构建定义的yaml文件如下所示:Azure devops Azure devops构建管道似乎两次恢复nuget软件包,azure-devops,nuget,azure-pipelines,dotnetcorecli,Azure Devops,Nuget,Azure Pipelines,Dotnetcorecli,我有一个构建管道,其中我有一个使用NuGetCommand的Nuget恢复步骤,该步骤运行良好 但是执行构建的下一步在缺少nuget包的情况下失败 构建步骤似乎试图第二次恢复nuget包,但这不起作用 (它没有这样做的凭据) 构建定义的yaml文件如下所示: trigger: - master pool: vmImage: 'windows-latest' steps: - task: CopyFiles@2 displayName: 'copy sql scripts'
trigger:
- master
pool:
vmImage: 'windows-latest'
steps:
- task: CopyFiles@2
displayName: 'copy sql scripts'
inputs:
SourceFolder: 'Resources/TestProject/Migrations/Sql'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)/SqlScripts'
- task: NuGetCommand@2
displayName: 'NuGet Restore'
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'config'
nugetConfigPath: './nuGet.config'
externalFeedCredentials: 'TelerikFeed'
- task: DotNetCoreCLI@2
displayName: 'Build ServiceHost projects'
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/ServiceHosts/**/*.csproj'
arguments: '-c Release -r win-x64 --self-contained false -o $(Build.ArtifactStagingDirectory) /p:SourceRevisionId=$(Build.SourceVersion)'
zipAfterPublish: false
- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
我还有一个nuGet.config文件,看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- remove any machine-wide sources with <clear/> -->
<clear />
<add key="MyFeed" value="https://pkgs.dev.azure.com/MyCompany/_packaging/NugetFeed/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Telerik_NuGet" value="https://nuget.telerik.com/nuget" />
</packageSources>
</configuration>
并将运行时标识符win-x64添加到csproj文件中
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>TestProject</AssemblyName>
<RootNamespace>TestProject</RootNamespace>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
Exe
netcoreapp3.1
测试项目
测试项目
win-x64
来自网络
您不必运行dotnet restore,因为它由所有需要执行还原的命令隐式运行,例如dotnet new、dotnet build、dotnet run、dotnet test、dotnet publish和dotnet pack。要禁用隐式还原,请使用--no restore选项
dotnet restore命令在某些显式恢复有意义的场景中仍然有用,例如Azure DevOps服务中的持续集成构建或需要显式控制何时进行恢复的构建系统
您应该在
dotnet publish
中使用--no restore
,或者删除dotnet restore
并让包通过dotnet publish隐式还原,这是正常行为<代码>生成
和发布
都执行还原。通过传递相应的命令行参数,--no restore
,您可以告诉它不要执行还原。感谢您的输入,我添加了此选项和其他一些内容(请参见编辑),现在它可以工作了。
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>TestProject</AssemblyName>
<RootNamespace>TestProject</RootNamespace>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>