Publish web application project failed
I have had huge problems on various projects with the “publish” functionality in Visual Studio 2008. I like the feature, you just click publish, choose a directory and the files that is needed on the webserver is placed in the folder and you can easliy copy it to your server or whatever.
The problem with it is that it seems to fail from time to time. The output window gives no clues what so ever what has gone wrong so it’s kind of hard to debug. When you google it you get all sorts of threads and post about people having problems with this but it seems like it a diffrent solution for it everywhere.
Anyway i gave up and started looking towards MSBUILD and found this great post about how to simulate the behavior of the publish feature with MSBUILD. You just create a Build.xml file and then you run msbuild.exe build.xml. My Build.xml file looks like this.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Run">
<Import Project="C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<PropertyGroup>
<OutputFolder>Publish</OutputFolder>
<ProjectDir>C:\code\</ProjectDir>
<CompilationDebug />
<CustomErrorsMode />
<ContentEditorsEmail />
<AdministratorsEmail />
</PropertyGroup>
<PropertyGroup Condition="$(Environment) == 'Test'">
<DeploymentFolder>C:\Staging\Test</DeploymentFolder>
</PropertyGroup>
<PropertyGroup Condition="$(Environment) == 'Live'">
<DeploymentFolder>C:\Staging\Live</DeploymentFolder>
</PropertyGroup>
<Target Name="Run">
<CallTarget Targets="Compile" />
<CallTarget Targets="Publish" />
</Target>
<Target Name="Clean">
<ItemGroup>
<BinFiles Include="bin\*.*" />
</ItemGroup>
<Delete Files="@(BinFiles)" />
</Target>
<Target Name="Compile" DependsOnTargets="Clean">
<MSBuild Projects="myproject.csproj" />
</Target>
<Target Name="Publish">
<RemoveDir Directories="$(OutputFolder)" ContinueOnError="true" />
<MSBuild Projects="myproject.csproj"
Targets="ResolveReferences;_CopyWebApplication"
Properties="WebProjectOutputDir=$(OutputFolder);OutDir=$(WebProjectOutputDir)\" />
</Target>
</Project>
This works great for me for now.
Let me guess: you use Subversion as your source control.
If yes, I am facing the same problem with publish not working with subversion. In my case solution is exporting the project and then publishing it.
HTH,
Nikola
How do you mean exporting?
But is it the ankhsvn plugin or some metadata on the files or something? You know anything more about it?
You can disable ankhsvn in source control options, restart visual studio and then the publish feature works.