I'm trying to Web Publish a .zip created by dotnet publish from Azure DevOps. There's a WinRM Web Publish task but it's unsatisfactory because it uses port 5986 and requires a self-signed certificate on the target server, which only lasts for one year.
Is it possible to use MSBuild instead such that it doesn't attempt a build and only does a publish?
I figure this should be possible because I can use Web Publish from Visual Studio and it doesn't use port 5986.
Do publish without build, you can use dotnet publish --no-build. You can check the additional options here. If you need to change the port, you can change it from the Program.cs file with this:
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://localhost:5054")
.UseStartup<Startup>()
MSBuild depends on or uses MSDeploy, which handles Web Publish. (I could see this from the summary of the publish profile in Visual Studio.)
There's an Azure DevOps task for this here...
https://github.com/rschiefer/MSDeployAllTheThings/tree/master/Tasks/MSDeployPackageSync
Related
I've got a build and release pipeline on Azure DevOps that runs dotnet publish on a Vue + .NET Core application and moves it to a server where I plan to run it with IIS.
If I remote into said server, navigate to the folder where my app is, and run dotnet App.dll, it runs on localhost:5000 and looks good. But when I go to IIS Manager and start the website from there, I go to the URL that I've got a certificate setup for and I get a 403 or a 404.
What exactly is happening behind the scenes when I start a website on IIS Manager?
Can I run IIS commands myself via command line for the sake of troubleshooting? Is there a page where I can read about these commands?
Here's what I did find, in case anyone is reading this.
I needed to take a close look at the web.config that was being generated by the dotnet publish command, that's sort of where the magic is happening/what IIS is looking at.
After that, I needed to install the .NET Core hosting bundle on the server IIS was running on.
We are building a webapp for our clients using ASP.NETZero template built on dotnet core 3.1.x
I am trying to create release pipeline in Azure DevOps and facing issues while publishing the changes of build pipeline to IIS similar way I did for traditional MVC5 or MVC6 .NET Framework based webapps.
The self-hosted devops agent is running on a different machine than production server where the webapp is published and the agent service account has access of the shared path of the \\server\inetpub-sharedhostingdir only.
Traditoinally, Copy Files task could replace app DLLs and all other files but in .NETCore there is an error like below:
Then I found out that this is because of changes how .NET Core 3.1.x hosting works.
I also tried to use 'OutOfProcess' in the web.config in the webapp but still getting same error and then I found this SO post and DLL hotswap info given by #MindingData.
So, my current bat to overcome this issue is using remote powershell in CD; I can stop the webapp and publish the new artifact. But there is cost for this step, I have to stop the site and replace all the DLLs which may roughly takes 30 seconds.
The remote Azure DevOps agent does not have access to do so right now and yet we have to add firewall exceptions to do so.
I am wondering if there is any other efficient alternative to publish .NETCore 3.1.x webapp using AzureDevOps agent running on a remote server? (as access of production server is restricted and we cannot deploy the azure agent on production machine.)
Because of these issues currently I need to move all the DLLs in 'backup' directory manually to make the hosting directory empty and then if I run the pipeline of first image, the 'Copy Files To' runs successfully and publishes the app well.
Any suggestions for improving the CD in current environment?
You may try using 'app_offline.htm' file for graceful shutdown of your running application and after deployment you can easily remove that file using powershell command task.
This approach should work as you have access of the deployment directory of the remote server. Steps are mentioned on the SO post.
I have a number of services which run via IIS and that are worked on daily. On my local machine these are run via IIS. When I was using .NET Framework this was easy, I would point to the source folder and it just worked. Now with .NET Core I must manually "publish" every time I make a change. Is there some way to automatically publish when I build or when changes are made?
You can create an Azure Devops (VSTS) account and configure build and release triggers.
This will basically pull your repository every-time you push to certain branch and then follow the build and release process you configured to deploy your solution to your IIS.
Here is a link with some more details to help you : https://medium.com/#taithienbo/build-and-deploy-an-asp-net-core-app-running-on-iis-using-azure-pipelines-e675041f62d4
I'm an asp.net developer and recently trying to archive asp.net-core.
Since it's quite new, I would like to ask, how do you launch a asp.net-core project in a Windows machine?
For normal asp.net, my approach is publishing the project using Visual Studio, bring everything to a Windows machine, use IIS to create a website and point the directory to my physical file.
How about a website that created by asp.net-core?
Do I need to install asp.net-core in server machine? (i don't prefer this)
What should I do with the published file? There are two folders generated after publishing the project:
netcoreapp1.0
PublishOutput
Well, you still can use the file system mechanism to publish an ASP.NET Core project from Visual Studio. But VS uses the dotnet CLI under the hood to do the same stuff. Usually you configure your deployment depending upon your hosting environment such as Windows Server and Linux Server.
For Windows Server
You have to install ASP.NET Core Module in order to publish on IIS successfully. This will also install .NET Core SDK. You can than have the advantages of SSL Terminations and others provided by IIS on Windows Server.
For Linux
You have to use the .NET Core SDK here as well for a published app to acquire the .NET Core runtime (This is why you get those 2 folders). You use Nginx or HAProxy to get all SSL Terminations, Port-Forwarding etc.
I am using Teamcity as my continuous integration server.
I have a Visual Studio project which needs to be deployed to IIS as a new application in default website in a remote Windows server.
How can I achieve this , either from command line or from any one of the Teamcity build runners.
I am new to this and have no idea of what to do. Please help me out.
JetBrains provides documentation for this scenario.
In a nutshell:
Configure web.config transforms to modify application settings based on your target environment (i.e. your test/prod DB connection strings)
Enable WebDeploy on the IIS server (for automated delivery of the site package to IIS)
Set up TeamCity build step to WebDeploy your project to IIS.