Hi,
I tried doing it like a website:
<MSBuild Projects="C:\MyTempWebsite.sln"
Targets="Publish"
Properties="Configuration=Debug;
Platform=AnyCPU;
PublishDir=D:\todelete\FINAL\;
ApplicationVersion=0.1.0.0;
PublisherName=my site;
PublishUrl=http://localhost/MyTempWebsite/;
InstallUrl=http://localhost/MyTempWebsite/">
<Output ItemName="OutputFiles" TaskParameter="TargetOutputs"/>
</MSBuild>
But it tells me that its an unpublishable project...
Thank you

Can you publish a web application using MSBuild on the command line?
K. Ravinder Reddy
You may want to show your @Content and @Binaries arrays defined earlier in your MSBuild xml file... So far everyone seems to be manually pushing files around, as there is nothing in the "Publish" wizard of the IDE to save the wizard output as an XML MSBuild file.
All you need is to pass a parameter to the WAP project, more details here:
http://forums.asp.net/1534682/ShowThread.aspx#1534682
Senthil Nathan.S
I also attempted to use We Deployment projects using my WebApplication template type project, and kept getting "unpublishable project" type errors. Perhaps on my case it has to do with web control type projects nested underneath my main web application which do not have a config file. Etiher way, it is kind of silly to use web project deployments for solutions that have more than one Web Application project in it as you will end up with as many web deployment projects as you have web applications in your solution. Best thing to do is use MSBuild and the WebApplication target to compile and publish ALL your Web Application projects at once. more about this here...
http://forums.asp.net/1534682/ShowThread.aspx#1534682
yeos_lee
Thanks guys. But as you already know, it is true that web deployment projects are for websites only.
Here's what i did... I simply created a custom task that reads the project file and copy only the files marked as content and the bin directory. So far, its been working pretty well.
Zac Boyles
For anyone interested in mimicking Publish from the command line for Web Application Projects here's what I did:
<Target Name="AfterBuild">
<Message Text="Copying to Deployment Dir:" />
<Copy SourceFiles="@(Content)" DestinationFolder="..\PreCompiledWeb\HelloWorld\%(Content.RelativeDir)" />
<CreateItem Include="$(OutputPath)\*">
<Output TaskParameter="Include" ItemName="Binaries"/>
</CreateItem>
<Copy SourceFiles="@(Binaries)" DestinationFolder="..\PreCompiledWeb\HelloWorld\bin" />
</Target>
Anthony M
Fwank wants to know how to publish a Web Application Project on the command line (and so would I)!
I'm currently using CruiseControl.Net.
When using WebSites the files are placed in the PreCompiledWeb folder, but after switching to Web Application Projects, they are not.
tviel
Fwank !
Can you post that custom task code please.
Yoni
An De Lafonteyne
S76
Hi Yoni,
Sorry for the late reply but here's my class. Hope you will find it useful. Let me know if you have any questions. Its an MSBuild task:
using
System;using
System.Collections.Generic;using
System.Text;using
Microsoft.Build.Framework;using
Microsoft.Build.Utilities;using
System.Xml;using
System.Xml.XPath;using
System.IO;namespace
WebApplicationDeployer{
///
<summary>///
This simple task open the web application project file and find all the files considered as///
content and copy all of them in the destination path in order to publish the application.///
</summary> public class WebAppDeploy : Task{
private string _WebAppRoot; private string _WebAppDestination; private string _WebAppFileName; private bool _Overwrite = false; public string WebAppRoot{
set { _WebAppRoot = value; } } public string WebAppDestination{
set { _WebAppDestination = value; } } public string WebAppFileName{
set { _WebAppFileName = value; } } public bool Overwrite{
set { _Overwrite = value; } } public override bool Execute(){
// basic validation of paths and fileNames if (!_WebAppRoot.EndsWith("\\"))_WebAppRoot +=
"\\"; if (!_WebAppDestination.EndsWith("\\"))_WebAppDestination +=
"\\"; if (!Directory.Exists(_WebAppRoot)){
this.Log.LogMessageFromText("The directory " + _WebAppRoot + " could not be found", MessageImportance.High); return false;}
if (!Directory.Exists(_WebAppDestination)){
this.Log.LogMessageFromText("The directory " + _WebAppDestination + " could not be found", MessageImportance.High); return false;}
if (!File.Exists(_WebAppRoot + _WebAppFileName)){
this.Log.LogMessageFromText("The file " + _WebAppRoot + _WebAppFileName + " could not be found", MessageImportance.High); return false;}
// Add a folder which is today's date (where the code will be copied)_WebAppDestination +=
DateTime.Today.Year + "-" + DateTime.Today.Month + "-" + DateTime.Today.Day + "\\"; if (!Directory.Exists(_WebAppDestination)) Directory.CreateDirectory(_WebAppDestination);EmptyDirectory(_WebAppDestination);
// copy all the necessary files for the web app. if (CopyFiles()) return CopyBin(); else return false;}
///
<summary>///
Copy the whole bin directory///
</summary>///
<returns></returns> private bool CopyBin(){
try{
//Directory.Move(_WebAppRoot + "bin", _WebAppDestination + "bin"); Directory.CreateDirectory(_WebAppDestination + "bin"); string fileName; foreach (string file in Directory.GetFiles(_WebAppRoot + "bin")){
fileName = file.Substring(file.LastIndexOf(
"\\") + 1); File.Copy(file, _WebAppDestination + "bin\\" + fileName, true);}
}
catch(Exception e){
this.Log.LogErrorFromException(e);}
return true;}
///
<summary>///
Empty the content of a directory///
</summary>///
<param name="strPath"></param> private void EmptyDirectory(string strPath){
string[] rootFiles = Directory.GetFiles(strPath); foreach (string file in rootFiles){
File.Delete(file);}
rootFiles =
Directory.GetDirectories(strPath); foreach (string dir in rootFiles) Directory.Delete(dir, true);}
private bool CopyFiles(){
string filePath, fileName, destFilePath; XmlDocument xDoc = new XmlDocument(); XmlNamespaceManager nManager = new XmlNamespaceManager(xDoc.NameTable);nManager.AddNamespace(
"ns", @"http://schemas.microsoft.com/developer/msbuild/2003");xDoc.Load(_WebAppRoot + _WebAppFileName);
// get all the 'content' and 'none' node. XmlNodeList contentList = xDoc.SelectNodes("//ns:Content | //ns:None", nManager); foreach (XmlNode node in contentList){
// only copy files considered as content or some none if(!(node.Name == "None" && node.ChildNodes.Count > 0)){
// get the value of the include attribute which is the file path from the app root.filePath = node.Attributes[
"Include"].Value;fileName = filePath.Substring(filePath.LastIndexOf(
"\\") + 1);filePath = filePath.Substring(0, filePath.LastIndexOf(
"\\") + 1); // Files located higher than the root will be included in the rootdestFilePath = filePath.Replace(
"..\\", ""); // Does the source file exist if (!File.Exists(_WebAppRoot + filePath + fileName)){
this.Log.LogMessageFromText("The file " + filePath + fileName + " could not be found. Skipping...", MessageImportance.Normal); continue;}
try{
this.Log.LogMessageFromText("Copying file '" + filePath + fileName + "'", MessageImportance.Low); // create the dir if it does'nt exist if (!Directory.Exists(_WebAppDestination + destFilePath)) Directory.CreateDirectory(_WebAppDestination + destFilePath); File.Copy(_WebAppRoot + filePath + fileName, _WebAppDestination + destFilePath + fileName, true); File.SetAttributes(_WebAppDestination + destFilePath + fileName, FileAttributes.Normal);}
catch(Exception e){
this.Log.LogMessageFromText("ERROR: Could not copy the file '" + _WebAppRoot + filePath + fileName + "' to '" + _WebAppDestination + destFilePath + fileName + "'", MessageImportance.High); this.Log.LogErrorFromException(e); return false;}
}
}
xDoc =
null; return true;}
}
}
ExtinctPencil
Take a look at Web Deployment Projects.
Sayed Ibrahim Hashimi
www.sedodream.com