Azure 在生成的包中包含 {Assembly}.styles.css

Azure include {Assembly}.styles.css in generated packages

我一直在尝试解决我的管道创建的 drops 不包含不同 .csproj 的 {Assembly}.styles.css 的问题。当我在本地发布时,它按预期工作,但不是在 Azure 管道上。

我还没有找到很多关于这方面的信息。 关于执行构建命令,但我希望有更简单/更好/内置的东西。

Yaml 的详细信息(看起来非常简单...我省略了测试和符号步骤)

steps:
- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 5.11.0'
  inputs:
    versionSpec: 5.11.0
    checkLatest: true

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'

- task: VSBuild@1
  displayName: 'Build solution **\*.sln'
  inputs:
    solution: '$(Parameters.solution)'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)\Blazor*************'
  inputs:
    SourceFolder: '$(system.defaultworkingdirectory)\'
    TargetFolder: '$(build.artifactstagingdirectory)\Blazor**************'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

在日志中我可以找到我无法真正理解的信息,例如:

Skipping asset 'D:\a\s\Blazor******\obj\Release\net6.0\scopedcss\bundle\Blazor******.styles.css' since copy to output directory option is 'Never'
Accepted candidate asset 'D:\a\s\Blazor******\obj\Release\net6.0\scopedcss\bundle\Blazor******.styles.css' because project mode is 'Root' and asset mode is 'CurrentProject' Skipping asset 'D:\a\s\Blazor******\obj\Release\net6.0\scopedcss\bundle\Blazor******.styles.css' since source type is 'Project'

有人有想法吗?

谢谢:)

这是我使用 blazor .net6 在 azure devops 上构建的,并且适用于范围 css。希望它有所帮助(更改变量中的项目名称)。由于构建任务,我个人必须先构建然后发布,但您可以只使用 dotnet 发布(删除 dotnet 构建)

variables:
  projectName: '**/ProjectName.csproj'
  BuildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 6.x'
  inputs:
    version: 6.x
- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: 'restore'
    projects: $(projectName)
- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    command: 'build'
    projects: $(projectName)
    arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish
    publishWebProjects: false
    projects: $(projectName)
    arguments: '--configuration $(BuildConfiguration) --output "$(build.artifactstagingdirectory)"'
    zipAfterPublish: true

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'