MS provide a command msbuild which is really helpful to published build on some specific location.
Before publishing web site, we need to create a publish profile using VS.
Note: the below contents requires to have VS 2012 (or VS2010 for that matter) and the Azure SDK on top of that. The features were not included in the RTM drop of VS2012.
After creating a publish profile in VS the following are created:
For eg:-
msbuild test.Web.csproj /p:DeployOnBuild=true /p:PublishProfile=Target
msbuild "G:\XXX\XX\XX\XX\test.Web\test.Web.csproj" /p:DeployOnBuild=true /p:PublishProfile=Target
Create a build.xml file thats look like below
Before publishing web site, we need to create a publish profile using VS.
Note: the below contents requires to have VS 2012 (or VS2010 for that matter) and the Azure SDK on top of that. The features were not included in the RTM drop of VS2012.
After creating a publish profile in VS the following are created:
- Start Visual Studio command prompt
- A publish profile (.pubxml file) under App_Data/PublishProfiles
- A website.publishproj in the root of the website
For eg:-
msbuild test.Web.csproj /p:DeployOnBuild=true /p:PublishProfile=Target
msbuild "G:\XXX\XX\XX\XX\test.Web\test.Web.csproj" /p:DeployOnBuild=true /p:PublishProfile=Target
msbuild test.Web.csproj /t:Rebuild /p:outdir="f:\target\" /p:Configuration=Release /p:Platform="Any CPU"
- 'test.web.csproj': Is a project solution. Before excuting command we need to navigate to solution path using cd command.
- '/p:DeployOnBuild=true': Set property true, in order to deploye once buid completed.
- '/p:PublishProfile': Is a published profile name that we may need to deployed on mentioned location
Create a build.xml file thats look like below
Start Visual Studio command prompt
Run msbuild build.xml
Run msbuild build.xml
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="Build">
<PropertyGroup>
<Build>$(MSBuildProjectDirectory)\Build</Build>
<ProjectFile>MyProject.csproj</ProjectFile>
<ProjectName>MyProjectNameInVisualStudio</ProjectName>
<CopyTo>$(MSBuildProjectDirectory)\CopyTo</CopyTo>
</PropertyGroup>
<Target Name="Build">
<RemoveDir Directories="$(Build)"/>
<MSBuild Projects="$(ProjectFile)" Properties="Configuration=Release;OutputPath=$(Build);OutDir=$(Build)/"></MSBuild>
<Exec Command="robocopy.exe $(Build)\_PublishedWebsites\$(ProjectName) $(CopyTo) /e /is
if %errorlevel% leq 4 exit 0 else exit %errorlevel%"/>
</Target>
</Project>
Thanks
No comments:
Post a Comment