0

I have been trying to fix the issue where the drops created by my pipelines do not contain the {Assembly}.styles.css of the different .csproj. When I publish locally, it works as expected, but not on Azure pipelines.

I haven't found many information about this. There is this Stackoverflow answer about doing a build command, but I was hoping there was something easier / better / built-in.

Details of the Yaml (Seems very straight forward...I left out test and symbols steps)

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

In logs I can find information that I can't really understand like:

Skipping asset 'D:\a\41\s\Blazor******\obj\Release\net6.0\scopedcss\bundle\Blazor******.styles.css' since copy to output directory option is 'Never'
Accepted candidate asset 'D:\a\41\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\41\s\Blazor******\obj\Release\net6.0\scopedcss\bundle\Blazor******.styles.css' since source type is 'Project'

Anyone has an idea?

Thanks :)

Shuryno
  • 532
  • 3
  • 13
  • 1
    Hi Shuryno; could I ask you to Edit your answer to include the relevant bits of your pipeline code? The answer is probably something specific about the way you build your code and publish the artifact, but without knowing precisely how your pipeline is doing those tasks, it is difficult to answer. – Vince Bowdren Dec 21 '21 at 14:44
  • Since we are using TFS(we will move to git soon) our pipelines is only made through UI, but I think I can copy the yaml. Let me see how I can do it. – Shuryno Dec 21 '21 at 14:50
  • 1
    @VinceBowdren Thanks for any help you can provide, I appreciate, I added some details, its not a complex pipelines. it is only starting. – Shuryno Dec 21 '21 at 15:02
  • From a look at the task settings in your pipeline, it looks like the css file *would* be included *if it existed* at all; so I can only conclude that it is simply not there. In your situation, I would temporarily add a powershell task - after the build task - to list the files present and hope I can figure out what else is missing, and why that might be. – Vince Bowdren Dec 21 '21 at 15:36
  • 1
    You're right, they are copied with that steps(This was a test, I usually output to a folder to try and only bundle relevant dlls ). They're found real deep in \obj\Release\net6.0\scopedcss\bundle of each project, but never moved from that, seems like the builds doesn't copy them natively, I was hoping to find something that prevent me from making a custom step. What bothers me Skipping asset {..}. copy to output directory option is 'Never', but I can't seem to find how to tell the system to copy a file that is build generated. I need to look into the local publish to see why it works. – Shuryno Dec 21 '21 at 15:51

1 Answers1

1

Here's my build on azure devops using blazor .net6 and works with scoped css. Hope it helps (change the project name in the variables). Personally I have to do a build then publish due to a build task, but you might be able to just use the dotnet publish (removing dotnet build)

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'
App Pack
  • 1,512
  • 10
  • 9
  • I added a publish step, now I have access to copy from the publish folder and not have to fetch all obj of every component csproj I have. – Shuryno Dec 21 '21 at 19:38
  • I totally needed that publish step. For some reason, I was using it locally for pushing from my machine. The content I was copying from output path on Azure seemed right, except, of course the {assembly}.styles.css and probably other thing would have been missing in the future, but the app is still relatively small. – Shuryno Dec 21 '21 at 20:39