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
Related
I'm attempting to get IIS to serve our ASP.NET 6 web application, but every time it complains of needing a default document. If I run the exe (kestrel) one it will serve it, but we want it to be hosted by IIS with the other components of the site.
I installed the 6.0.10 runtime w/ hosting package and these are the results when listing runtimes:
When looking at the site modules, I think it should have what is needed (think the AspNetCoreModuleV2 one handles the compiled routing scenario?):
Have rebooted the server and the app pool specifically, set to No Managed Code, and whenever I attempt to load the page at the localhost level, I get:
The views are compiled so I don't think I even need IIS to open views locally in any capacity.
Everything you've posted ticks off the major deployment steps for hosting a .NET 6 project on IIS:
Installed the .NET Core 6.0 Runtime Windows Hosting Bundle
Set up the IIS app pool with "No Managed Code"
Rebooted the server: "Have you turned it off and on again?"
After our exchange in the comments, the only thing that appeared to be missing is to use the .NET publish command; not the build command.
When deploying to IIS, you'll want to run the dotnet publish command and then deploy those artifacts to your IIS server. From the docs:
The dotnet publish command's output is ready for deployment to a hosting system (for example, a server, PC, Mac, laptop) for execution. It's the only officially supported way to prepare the application for deployment. Depending on the type of deployment that the project specifies, the hosting system may or may not have the .NET shared runtime installed on it.
You also may want to review: Publish .NET apps with the .NET CLI.
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 am trying to figure out a better approach for the production deployment of our asp.net MVC applications. At present we deploy the application using the "Publish" feature in visual studio. I have listed our current process below.
1-> Open the latest code in Visual studio.
2-> Right click on the web project and Publish it to a folder using the "release" configuration.
3-> Copy the contents of this folder to the production machine.
I am not sure if this is the right approach. Are there any better alternatives available? I cannot use deployment tools such as "Octopus deploy" as my organization doesn't want to spend money on them.
does anyone have any recommendation for a better process?
Thanks
Suneeth
Octopus deploy brings a lot of control and visibility to the deployment chain. It also handles the hub and spoke model with its Server and agents.
So, to do it manually, I would go for:
Powershell to Deploy
A Windows service, to handle the deployment payload
I do this mechanism, as a fall back strategy to Octopus Deploy.
Hope that helps.
I have been doing some work recently with publishing mvc applications on visual studio 2012. I have been using publish profiles to configure web deploy to different environments. I have also been using web transforms to transform my web.config as per each of my publish profiles.
For each of my target environment, I have web deploy and package publish profile. So dev has 2, qa has 2 etc. This is to give me the option to either web deploy or package up. Is there any way that I can just have the web deploy profile and after I web deploy, the package also gets created and placed on disk? So I only need the one publish profile per environment.
If 2 publish profiles are needed per environment, can I consolidate the transform in to one transform file instead of having a transform for each profile - as the transform is identical as the target environment is the same.