【问题标题】:Azure Pipeline for .NET Core 3.0 P9 does not work.NET Core 3.0 P9 的 Azure 管道不起作用
【发布时间】:2020-01-09 08:18:54
【问题描述】:

我有一个使用 3.0 P9 的简单 Blazor 项目,它在我的本地机器上构建良好,将其签入 azure 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)'

【问题讨论】:

    标签: azure-devops yaml azure-pipelines devops


    【解决方案1】:

    .NET Core 3.0 P9 的 Azure 管道不起作用

    要解决此问题,请在任务Visual Studio build 之前添加dotnet restore 任务:

    - task: DotNetCoreCLI@2
    
      displayName: 'dotnet restore'
    
      inputs:
    
        command: restore
    
        projects: '**/YourProjectName.csproj'
    
        vstsFeed: 'XXXX'
    

    发生错误是因为 dotnet cli 最初没有创建所有必需的文件。执行 dotnet restore 会添加所需的文件。

    希望这会有所帮助。

    【讨论】:

    • 现在我收到了这个错误。我根据您的 cmets 更新了 yaml,以在 OP 错误 CS8652 中显示最新的 yaml:“可空引用类型”功能目前处于预览状态,不支持。要使用预览功能,请使用“预览”语言版本。”
    • 经过深入研究发现.NET Core 3.0 SDK处于预发布状态,正式发布的Visual Studio不支持,SDK团队建议使用预览版SDK的项目使用预览版Visual Studio .因此,我们可能需要使用私有代理构建此项目并预览 Visual Studio。由于您使用的是windows-latest,这可能是您收到此错误的原因,请查看此票:github.com/dotnet/arcade/issues/3035#issuecomment-502720454
    • 我的 vs 中没有该选项,因为我已经在使用 vs2019 预览版 3,我的问题与本地构建无关,它在调试和发布中都可以正常工作。我试过windows-latest 哪个vs2019 和win2016,没有一个代理docs.microsoft.com/en-us/azure/devops/pipelines/agents/… 提供vs2019 预览版。
    【解决方案2】:

    这已经帮我解决了

    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)'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 2020-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多