I have a Blazor WASM Pipeline Release build that was running well until I upgraded to .NET5.
Lately I get the following error: ...\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): Error MSB4018: The "GenerateServiceWorkerAssetsManifest" task failed unexpectedly. followed by System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\a\1\s\ClientSide\BlazorProject\obj\Release\net5.0\service-worker-assets.js'.
My yaml-file:
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: '**/BlazorProject.csproj'
solutionSln: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
command: 'restore'
restoreSolution: '$(solutionSln)'
feedsToUse: 'select'
noCache: true
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)/WebClient.zip"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
clean: true
createLogFile: true
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'censored'
appType: 'webApp'
WebAppName: 'nextGenClientTest'
packageForLinux: '$(build.artifactStagingDirectory)/WebClient.zip'
So for some reason I think it cannot find the file service-worker-assets.js, but I don't know why.
For the ones wondering why the structure might be strange: I have a solution file that I use to restore nuget-packges and in this pipeline I just want to build a specific project BlazorProject.csproj (which was working fine until I upgraded to .NET5).
Anyone knows, what's suddenly up with service-worker-assets.js?
Azure DevOps: Blazor Deployment fails in Pipeline Build
There is an issue about it:
Blazor Service Worker Asset Manifest path construction bug
And this issue was moved to the Next sprint planning milestone for future evaluation / consideration. And aspnetcore team will evaluate the request when they are planning the work for the next milestone.
Besides, in order to ensure that you have upgraded your project correctly, please refer to the following documents for some more details:
Update Blazor WebAssembly projects
Related
Hello I am having a problem. Suppose I am having a simple web app and pushed it to Azure Repos. Now I set up a build pipeline using yaml and then I set up a release pipeline which will require an artifact from the build pipeline. So I am using PublishPipelineArtifact#1. The build pipeline runs fine but my release pipeline fails with error Deployment of msBuild generated package is not supported. Change package format or use Azure App Service Deploy task. D:\a\r1\a_ReleasePipelines\drop\WebApp.zip.
So how to provide artifact required by release pipeline in correct naming sequence?
Below is my yaml for build pipeline
`
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- 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: PublishPipelineArtifact#1
inputs:
targetPath: '$(build.artifactStagingDirectory)'
publishLocation: 'pipeline'
`
Next I am setting up a simple release pipeline using empty job and there in Add Artifact I am supplying the project name and source.
From the MS build arguments in your YAML, it is for Web Deploy method.
If you would like to change the method to Zip deploy, you could follow this official link to change the Arguments: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-rm-web-app-deployment-v4?view=azure-pipelines&viewFallbackFrom=azure-devops#error-publish-using-zip-deploy-option-is-not-supported-for-msbuild-package-type
Publish build artifacts is recommended: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/publish-build-artifacts-v1?view=azure-pipelines&viewFallbackFrom=azure-devops
Here is a sample,
steps:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
In your release pipeline, you need to specify the pipeline artifacts from build :
And use Azure App Service Deploy task for the deployment.
Build pipeline sample:
Release pipeline sample:
I'm working on a yaml deployment. I am trying to define the aspnetcore_environment. I have tried two ways. One is in the yaml file itself (see below), and the other is in the pipeline variables. Neither seem to work. Luckily I managed to solve it by adding the variables directly to the application settings in azure itself. But I would think I should be able to set this from the yaml deployment file. Well that's my question if it's possible.
It is a .net 6.0 mvc asp.net project. The project is a App Service in azure. It is my first time attempting to do a yaml deployment and this is what I've gotten so far.
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
ASPNETCORE_ENVIRONMENT: 'Acceptance'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '**\[project folder]\*.csproj'
vsVersion: '17.0'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="[app service name]"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishPipelineArtifact#1
inputs:
targetPath: $(build.artifactStagingDirectory)
artifact: 'drop'
publishLocation: 'pipeline'
- task: DownloadPipelineArtifact#2
inputs:
buildType: current
artifactName: 'drop'
targetPath: $(Pipeline.Workspace)/drop
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: '[subscriptionName]'
appType: 'webApp'
WebAppName: '[AppserviceName]'
packageForLinux: '$(Pipeline.Workspace)/drop/*.zip'
This page told me how to set the ASPNETCORE_ENVIRONMENT setting.
Yaml deploy succeeding but using wrong ASPNETCORE_ENVIRONMENT
When you define the aspnetcore_environment in the yaml file itself or in the pipeline variables, it could only be used for current pipeline instead of your the application.
That is the reason why why none of them work. You could add a command line task to echo this variable: echo $(ASPNETCORE_ENVIRONMENT).
To use the aspnetcore_environment for your application, you should define your own environment variable, click to your site → All Settings → Application settings:
Add an app setting in the "App settings" section:
So, what you are doing now is correct.
I have a blank WinUI3 desktop app:
I would like to build this app in an AzureDevops build pipeline:
pool:
vmImage: 'windows-2022'
variables:
solution: '$(Build.SourcesDirectory)/apps/windows/WinUI3VS2022NET6BlankApp/WinUI3VS2022NET6BlankApp.sln'
buildPlatform: 'x64'
buildConfiguration: 'Release'
steps:
- task: UseDotNet#2
displayName: Use .NET 6.0
inputs:
packageType: 'sdk'
version: '6.0.x'
- checkout: self
fetchDepth: 1
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
# Failure here :D
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:PublishReadyToRun=false'
I'm getting this error:
C:\hostedtoolcache\windows\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(293,5): error NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Please verify you are using a supported runtime identifier, or set the PublishReadyToRun property to false. [D:\a\1\s\apps\windows\WinUI3VS2022NET6BlankApp\WinUI3VS2022NET6BlankApp\WinUI3VS2022NET6BlankApp\WinUI3VS2022NET6BlankApp.csproj]
I have tried setting PublishReadyToRun to false in the .csproj and .wapproj files, without luck.
The app builds fine locally with Visual Studio 2022.
Any ideas how I can build this blank WinUI 3 app in AzureDevops?
Turns out the correct place to disable PublishReadyToRun is in the:
Properties/PublishProfile/<profile name>.pubxml
file instead of the .csproj file.
I'm trying to publish a couple of pipeline artifacts during a build so that I can use them in a build of another solution.
My first build builds and tests the soltuion using the following yaml
- stage: build_test_release
displayName: Build
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
jobs:
- job: build
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
This all works great and I've been able to do deployments using this yaml in the same file
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'azuresubscription'
appType: 'webApp'
WebAppName: 'webappname'
deployToSlotOrASE: true
ResourceGroupName: 'resourcegroupname'
SlotName: 'staging'
packageForLinux: '$(build.artifactStagingDirectory)/**/projectToPublish.zip'
I'm now trying to publish some of the projects which were build as Pipeline Artifacts so that I can use them in the build of another solution which references them. The following publish task gives me the error:
"##[error]Path does not exist: D:\a\1\a**\projectToPublish.zip"
- task: PublishPipelineArtifact#1
inputs:
targetPath: '$(build.artifactStagingDirectory)/**/projectToPublish.zip'
artifact: 'artifactname'
publishLocation: 'pipeline'
What am I missing here? I've been thinking of moving the projects which are referenced by both soltuions into their own solutions and adding them as nuget packages or something similar. The projects I am trying to publish as artifacts to be used in the second solution are both WCF Client projects.
Thanks!
The issue is that the task you're using, Publish Pipeline Artifacts, does not support wildcards for the 'File or directory path' argument. For this task $(build.artifactStagingDirectory) is replaced with D:\a\1\a\, in the second directory named a Azure DevOps is looking for a sub directory named ** which does not exist and causes the shown error. The other task AzureRmWebAppDeployment#4 you're using does support wildcards.
See the image below, where Azure DevOps shows in the the UI that the PublishPipelineArtifact#1 task does not support wildcards in targetPath:
Second I'm wondering why you're using a wildcard, because the task VSBuild#1 will just drop the package in the build.artifactStagingDirectory which should make the path $(build.artifactStagingDirectory)/projectToPublish.zip to locate the package.
In AzureRmWebAppDeployment#4 you have
'$(build.artifactStagingDirectory)/**/WebProjectToPublish.zip'
And in PublishPipelineArtifact#1 you have a different name
'$(build.artifactStagingDirectory)/**/projectToPublish.zip'
I'm using AzureDevOps for my .netCore service but when I make the build I have a problem with versions.
This service uses a nugetFeed and my YML file is like this:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
-task: NuGetCommand#2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: 'FeedsName'
includeNuGetOrg: false
versioningScheme: 'off'
-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)'
I don't undertand why if I download my code and compile using VS I don't have any problem, but make this file for the build I Have this answer:
[error]The nuget command failed with exit code(1) and error(Errors in d:\a\1\s\XXX.Services.XXX.DTO\XXX.Services.XXX.DTO.csproj
Unable to resolve 'System.Xml.XmlDocument (>= 4.3.0)' for '.NETCoreApp,Version=v2.1'.
Unable to resolve 'System.Runtime.Serialization.Formatters (>= 4.3.0)' for '.NETCoreApp,Version=v2.1'.
Thanks for the help!
You are missing a task 'nuget tool installer' before your nugetcommand, otherwise nuget runs with an outdated version of nuget (4.1 per default, 4.3 or newer required for netstandard and netcore). Visual-studio already contains an uptodate version of nuget.
add the following to your yaml before your nugetcommand:
- task: NuGetToolInstaller#0
displayName: 'Install Nuget'
inputs:
versionSpec: '4.x'
checkLatest: true