我有一个使用3.0 P9的简单Blazor项目,该项目可以在本地计算机上很好地构建,将其检入天蓝色devops,创建了获取管道的管道
C:\ hostedtoolcache \ windows \ dotnet \ sdk \ 3.0.100-preview9-014004 \ Sdks \ Microsoft.NET.Sdk \ targets \ Microsoft.PackageDependencyResolution.targets(234,5): 错误NETSDK1004:资产文件 找不到'd:\ a \ 1 \ s \ projectname \ obj \ project.assets.json'。运行 NuGet软件包还原以生成此文件。进程'msbuild.exe' 退出,代码为“ 1”。
使用以下Yaml运行管道时(将任务UseDotNet @ 2和DotNetCoreInstaller @ 0添加到默认生成的管道代码中)
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: DotNetCoreInstaller@0
displayName: 'Install .net core 3.0 (preview)'
inputs:
version: '3.0.100-preview9-014004'
- task: UseDotNet@2
inputs:
version: 3.x
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/projectname.csproj'
- task: VSBuild@1
inputs:
solution: '$(solution)'
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: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
答案 0 :(得分:1)
.NET Core 3.0 P9的Azure管道不起作用
要解决此问题,请在任务dotnet restore
之前添加一个Visual Studio build
任务:
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/YourProjectName.csproj'
vstsFeed: 'XXXX'
发生错误是因为dotnet cli最初并未创建所有必需的文件。进行dotnet还原会添加所需的文件。
希望这会有所帮助。
答案 1 :(得分:0)
这为我解决了
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Install .net core 3.0 (preview)'
inputs:
version: '3.0.100-preview9-014004'
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'