Using MSBuild to deploy an ASP.NET website project

39 Views Asked by At

I have an ASP.NET website project (the ones without a .csproj file) and I want to have it deployed to an IIS server using web deploy, but the msbuild task only runs a build and does not deploy it.

For the website I made a .msbuild file which is used in the msbuild command to build the project.

I have a similar setup for a web application project that uses a .csproj file and it does the deployment fine, so I want to know what I am missing for the website.

Both projects have publish profiles (.pubxml) which is where the deployment info gets saved.

The msbuild commands being triggered looks like this:

Web Application
msbuild -r WepApplication.csproj /p:Configuration=Debug /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:AllowUntrustedCertificate=True

Website
msbuild -r WepSite.msbuild /p:Configuration=Debug /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:AllowUntrustedCertificate=True

So they are identical, except for the fact that the application references the .csproj file, while the website references the .msbuild file

The msbuild file's contents are as follows:

<Project
        xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
        DefaultTargets = "PrecompileWeb">
        <Target Name = "PrecompileWeb">
                <AspNetCompiler
                        VirtualPath="/"  
                        PhysicalPath=".\"  
                        TargetPath=".\Built" 
                        Force = "true"
                        Debug = "true"/>
        </Target>
</Project>

I used this link as a reference on making the .msbuild file, but I do not see any parameters related to publishing withing the AspNetCompiler task.

These builds and deployments are triggered via a workflow on a build server, and the IIS server is separate, so I cannot make use of the msbuild Copy task since the build server cannot access the storage of the IIS server.

Any ideas on if and/or how this can be achieved would be much appreciated.

0

There are 0 best solutions below