Solved

Publish ASP.NET 2.0 Website Using MSBuild

Posted on 2011-09-05
3
423 Views
Last Modified: 2012-05-12
Hi all,

I have a VS2005 solution which consists of a classlibrary and a website (not a web application!).

I have created a a script to use MSBuild to publish the website.

Unfortunately, when it comes to publishing the website, it give the dreaded "MSB6006: aspnet_compiler.exe execited with code 1"

I think it is something to do with the fact that the website in the solution references the classlibrary project, but I'm not sure how to handle it or what settings to change.

I have attached the code from my build file

Any help is much appreciated.

Thanks.

resourcesys.


<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="All">

	<!--We import the comminity tasks project so we can use there custom tasks in the build file -->
	<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
  
  <!--======================================================================================================================= -->
  
  
  <!--======================================================================================================================= -->

 	<PropertyGroup>
		<ProjectDir>P:\Builds\REP_Testing</ProjectDir>

		<SourceCode>$(ProjectDir)\SourceCode</SourceCode>
		<BuiltSolution>$(ProjectDir)\BuiltSolution</BuiltSolution>
		 <PublishedWebsite>$(ProjectDir)\PublishedWebsite</PublishedWebsite>

		<SvnRepoPath>http://performoee:8080/svn/REP_Testing/trunk</SvnRepoPath>
		<SvnUsername>ccnet</SvnUsername>
		 <SvnPassword>ccnet</SvnPassword>

		<Major>0</Major>
		<Minor>0</Minor>
		<Build>0</Build>
		<Revision>0</Revision>
	</PropertyGroup>
  
  <!--======================================================================================================================= -->
  
  
  <!--======================================================================================================================= -->

  	<!--Get rid of old source code by deleting and recreating the directory -->
	<Target Name="CleanSourceCodeDirectory">
		<RemoveDir Directories="$(SourceCode)" />
		<Message Text="Source Code Directory Cleaned"/>
	</Target>

  <!--======================================================================================================================= -->
  
  
  <!--======================================================================================================================= -->

  	<!--Get the latest code form the repository -->
	<Target Name="CheckoutSourceCodeFromRepository" DependsOnTargets="CleanSourceCodeDirectory">
		<SvnExport RepositoryPath="$(SvnRepoPath)" LocalPath="$(SourceCode)" Username="$(SvnUsername)"  Password="$(SvnPassword)">
			<Output TaskParameter="Revision" PropertyName="Revision" />
		</SvnExport>

      		<copy sourcefiles="$(SourceCode)\REP_WebSite\web.publish.config" destinationfiles="$(SourceCode)\REP_WebSite\web.config" />
		
		<delete files="$(SourceCode)\REP_WebSite\web.publish.config" /> 
       		<delete files="$(SourceCode)\REP_WebSite\web.template.config" /> 

  		<Message Text="Checkout Of Source Code For Revision: $(Revision) Complete"/>
	</Target>

  <!--======================================================================================================================= -->
  
  
  <!--======================================================================================================================= -->

  	<!--Set values for version numbers in the AssemblyInfo.vb file -->
	<Target Name="SetVersionProperties" DependsOnTargets="CheckoutSourceCodeFromRepository">
		<Time Format="yyyy">
			<Output TaskParameter="FormattedTime" PropertyName="Major" />
		</Time>

		<Time Format="MM">
			<Output TaskParameter="FormattedTime" PropertyName="Minor" />
		</Time>

		<Time Format="dd">
			<Output TaskParameter="FormattedTime" PropertyName="Build" />
		</Time>
    
		<Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>
    
		<AssemblyInfo CodeLanguage="VB" OutputFile="$(SourceCode)\REP_WebSite\Include\AssemblyInfo.vb" AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)" AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)" AssemblyTitle="REP_Testing" AssemblyDescription="$(SvnRepoPath)" Guid="3d5900ae-111a-45be-96b3-d9e4606ca793" Condition="$(Revision) != '0' "/> 

  		<Message Text="Version Numbers In Assembly File Set"/>
	</Target>

  <!--======================================================================================================================= -->
  
  
  <!--======================================================================================================================= -->

  	<!--Build the solution -->
	<Target Name="BuildSourceCodeSolution" DependsOnTargets="SetVersionProperties">
		 <AspNetCompiler VirtualPath="/REP_WebSite" PhysicalPath="$(SourceCode)\REP_Website\"  TargetPath="$(PublishedWebsite)\" Clean="true" Force="true"  Debug="true" Updateable="true" />

		<Message Text="The Solution Has Built Successfully"/>
	</Target>

  <!--======================================================================================================================= -->
  
  
  <!--======================================================================================================================= -->

	<Target Name="All">
		<CallTarget Targets="CleanSourceCodeDirectory" />
		<CallTarget Targets="CheckoutSourceCodeFromRepository" />
		<CallTarget Targets="SetVersionProperties" />
		<CallTarget Targets="BuildSourceCodeSolution" />
	</Target>
  
</Project>

Open in new window

0
Comment
Question by:resourcesys
3 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
Comment Utility
There could be multiple reasons for the error. The thread http://forums.asp.net/t/1051551.aspx deals with it.
0
 
LVL 28

Accepted Solution

by:
strickdd earned 500 total points
Comment Utility
Not sure what version of visual studio you are using, but I highly recommend web deploy pojects. These use MSBuild XML to compile the website based on your rules and make it MUCH easier to do:

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=25163
0
 

Author Closing Comment

by:resourcesys
Comment Utility
Used a web deployment project and with a little tweeking everything worked correctly.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now