I'm trying to deploy a Blazor WASM Hosted app from our Git repo on our DevOps server using a DevOps Build pipeline and a separate release pipeline.
The project comprises of a Server project and a Client project (as per the standard structure created by the Blazor WebAssembly Hosted template in VS).
I've used the classic editor and the ASP.NET Core template and the site loads, but the console shows HTTP errors connecting to the server, which makes me think I've deployed the Client project not the Server project. I'm pretty sure that's the case because my Drop artifact contains a file called Client.zip.
How can I change this to deploy the Server app instead?
(There are a number of questions on this already, e.g. here, but none of the cover the classic editor approach)
Blazor WebAssembly apps can be deployed to Azure App Services on Windows, which hosts the app on IIS. Deploying a standalone Blazor WebAssembly app to Azure App Service for Linux isn't currently supported.
Run on WebAssembly or the serverBlazor can run your client-side C# code directly in the browser, using WebAssembly. Because it's real . NET running on WebAssembly, you can re-use code and libraries from server-side parts of your application. Alternatively, Blazor can run your client logic on the server.
This is the complete process that got it working for me:
I haven't tried this, but this post by muddybeard210 on the GitHub post Blazor WASM ASP.NET Core Hosted Azure Devops Only Publishes Client/Shared folder gave me the clue as to how to get this working in the classic editor.
- task: DotNetCoreCLI@2 displayName: Publish inputs: command: 'publish' publishWebProjects: false projects: '**/SkillBoard.Server.csproj' arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
It is important to note that publishWebProjects is set to false. This is because "If true, the task will try to find the web projects in the repository and run the publish command on them. Web projects are identified by presence of either a web.config file or wwwroot folder in the directory." - Azure devops info button
Due to this being true originally, it was selecting Client every time because the CLIENT project has a wwwroot folder. With publishWebProjects set to false, you can specify a particular project with projects and use the traditional wild card characters.
In the pipelines in VS, choose to add a new pipeline:
Click the 'Use the classic editor' link at the bottom
On the next page pick the repo
Choose the ASP.NET Core template:
That gets you this:
Then, you just need to change some of the settings on the Publish task:
On that task, untick 'Publish web projects' so the Path to project(s) box is shown:
Then click the link icon and choose to Unlink:
And finally enter a path to just your Server project in the format **/YourWebServerProject.csproj
:
And that's it. When you run the pipeline your drop should now contain a file called Server.zip instead of Client.zip:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With