Publish ASP.net project with MSBuild

Source: Internet
Author: User

  Method 1: To execute a custom MSBuild script file by calling MSBuild Step one: Create an MSBuild script file and copy it to the path where the target project is located. Step two: Use MSBuild to execute the above script file.      [msbuild.exe Path]/p:publishproject=[target project]; Configuration=release; Publishdestination=[publish destination dir]/t:publishtofilesystem [MSBuild file]         Example:   & nbsp   MSBuild script file (saved as Sampleproject.build):

<?xml version= "1.0" encoding= "Utf-8"?> <project toolsversion= "4.0"
Publishtofilesystem "
         xmlns=" http://schemas.microsoft.com/developer/msbuild/2003 ">
     <import Project = "${publishproject}"/>
     <target name= publishtofilesystem "dependsontargets=" Pipelinepredeploycopyallfilestoonefolder ">
          <ItemGroup>
               <publishfile include=" ${_ Packagetempdir}\**\*.* "/>
          </ItemGroup>
          <copy sourcefile=" @ (publishfile)
                Destinationfiles= "@ (publishfile-> ' $ (publishdestination) \% (recursivedir)% (Filename)% (Extension) ')"
                skipunchangedfiles= "True"/>
     </Target>
</Project>
  command line execution:>cd C:\Workspace\SampleProject >MSBuild/p:PublishProject=SampleProject.csproj; Configuration=release; Publishdestination=\\192.168.1.2\sampleproject/t:publishtofilesystem Sampleproject.buildMethod 2: With Nant or similar tools, first invoke MSBuild compilation, then copy the result file to the target publishing pathStep One: Call MSBuild compilation target the path to the project compilation result is: [asp.net project dir]/obj/[debug/release]/package/packagetmp Step two: Copy the results from the previous step to the publish path       Example (Nant script):
<exec program= "${msbuild.exe}" workingdir= "${sampleprojectdir}" >
     <arg value= "Sampleproject.csproj"/ >
     <arg value= "/p:configuration=release"/>
     <arg value= "/clp:errorsonly"/> <arg
     value = "/t:pipelinepredeploycopyallfilestoonefolder"/>
</exec>
<copy todir= "${publishdestination}" "Overwrite=" True >
     <fileset basedir= "${sampleprojecttmppackagedir}" >
          <include name= "**.*"/ >
     </fileset>
</copy>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.