Deploy web application on IIS with FAKE - web-deployment

Im trying to deploy asp.net mvc application to IIS on a remote PC with Fake.
I can build everything successfully. I also make nuget package of my webapp as Fake.Deploy
use nuget packages for deployment. but what should I add in my fsx script in nuget to stop IIS, then move the bin and content of a new site into virtual directory and then start IIS?
I dont want to use octopus deploy, so some fake script or cmd line would be just fine.

You can write any .NET(F#) code in *.fsx file.
As far as I know you should be able to reference FakeLib.dll and use all available helper functions
#r "FakeLib.dll"
open System.Diagnostics
open Fake
// Stop IIS process
Process.Start(ProcessStartInfo("iisreset.exe", " /stop"))
// Copy missing/updated files
XCopy "your source directory path" "your destination directory path"
// Start IIS process
Process.Start(ProcessStartInfo("iisreset.exe", " /start"))

Related

ASP.NET MVC project to push to a remote server

I have a ASP.NET MVC project locally, but want to push to a remote server so that others can use that website. I have login access to the remote server.
Is this what i need to do?
1) add a folder to IIS in the remote server
2) copy my files to the folder on remote server. If so, which files should i copy?
If you're using Visual Studio (not code) then right click on the project and select publish, then select the options to publish to a local folder. Copy all files in your published folder to your server.
If you're using ASP.NET Core then you can also navigate to the project folder and use the following command
dotnet publish -c Release -o PUBLISH_PATH_HERE
You will need to ensure that the server has your version of .NET runtime installed.
Create a release publish profile, publish, grab the files from the directory it published to. This is the simplest way. You can automate this process if you have many releases. For example publishing directly to the server or checking code into a source control of some kind and having it publish to the server.

Create directory in web deploy package?

I have an ASP.NET WebForms application which I would like to publish to a Web Deploy package and deploy using the deploy.cmd script generated as part of the Web Deploy package. This basically works fine but I have one problem.
My application generates image files which are stored in a temporary directory as part of the web site (basically a subdirectory of the IIS site's physical location called temp). However, whenever I deploy my site using the deploy.cmd script, this directoty is deleted. Instead, I would like the deploy script to make sure the directory is present and that the IIS user has access to it. Is this possible to do with Web Deploy out of the box?

Precompile ASP.NET Application after Installation

I have an ASP.NET Application compiled into installation package using INNO Setup installer. When I install an application to the dedicated server I want to precompile the whole application so it runs smoothly when first user arrives.
The problem is that only thing I know is the installation path. But what I need is the virtual path of the application in IIS to run this command:
aspnet_compiler -v AppVirtualPath
In my case, the application already exists in IIS and is mapped to the installation directory. I've been trying use the appcmd.exe to get virtual path by physical path. No luck so far.
Any suggestions would be greatly appreciated.

Opening web project set to IIS directory in machine without IIS, pointing to embedded server

I can open a web project in TFS; however, in my QA environment I have to change it to use IIS. In my local dev environment, I don't have IIS and can't install it.
New company rules deny access in QA to me and I can't open my web project to fix it in my machine.
When I open the project I receive "The Web Application Project ... is configured to use IIS. To access local IIS Web sites, you must run Visual Studio in the context of an administrator account." Then I open as administrator but VS asks for the virtual directory to be creatred on my IIS.
The NgM link can really help, but if you need a step-by-step way than go to your .csproj file property. Make it writable, open it in a text editor and search for <UseIIS>True</UseIIS> turn it to <UseIIS>False</UseIIS>. Open solution, get the latest version and when you receive a warning, keep the local version of your modified .csproj. You can too check-in your modified .csproj to stop troubles in the next latest version.
bye

Precompilation for Deployment

After exploring Precompilation for Deployment topic I want to enhance my build process. Now, what I do is:
prepare web site using Web One Click Publish, for instance to c:\www\app directory, and that directory is available in IIS via app (localhost/app)
I launch aspnet_compiler.exe -v app c:\www\appprecompiled -f
Now I have ready precompiled application in c:\www\appprecompiled and everything is fine. However my application is quite big, and Publishing it (step 1) take about 5 minutes from scratch. So I wonder if it is possible to avoid step one , and perform step 2 (precompilation) with source folder pointing to solution folder. I tried something like this:
aspnet_compiler.exe -v codeapp c:\code\app -f
Where c:\code\app is the folder with web.config etc files, basically it's a project with web site and that folder is avaliable via http://localhost/codeapp.
But when launching that command, I get errors about missing global.asax or web.config errors:
C:\code\app\obj\debug\package\packagetmp\web.config(18):
error ASPCONFIG: It is an error to use
a section registered as
allowDefinition='MachineToApplication'
beyond application level. This error
can be caused by a virtual directory
not being configured as an
application in IIS.
And for the record, I use Application, not Virtual Directory.
So is there a way to perform precompilation on a plain web site folder?
I used
aspnet_compiler -p
physicalOrRelativePath -v / targetPath
from http://msdn.microsoft.com/en-us/library/ms227976(v=VS.80).aspx and removed obj folder prior to executing it, and precompilation works :)

Resources