سؤال

I am migrating current solution from VS2010 to VS2012, since web deployment projects are not supported i am trying "Publish" feature on the project.

My requirement is to run "Publish" on the project while running the build. This is a ".csproj" with publish method "File System" also on settings tab of publish i have "Precompile during Publishing" and "Merge all outputs into single assembly".

I can manually run publish by right clicking on project and selecting "Publish" and it gives desired single assembly and copies it to right location, i just need this to run on build

I have tried following to no avail

Adding single line to .csproj file

    <DeployOnBuild>true</DeployOnBuild>

tried adding following lines to .csproj

<FilesToIncludeForPublish>OnlyFilesToRunTheApp</FilesToIncludeForPublish>
<DeployOnBuild>true</DeployOnBuild>
<DeployTarget>Package</DeployTarget>
<PackageAsSingleFile>true</PackageAsSingleFile>

Command line

MSBuild C:\MyProj.csproj /p:DeployOnBuild=true /p:PublishProfile=WebDeploy /p:CreatePackageOnPublish=True /p:VisualStudioVersion=11.0

Above command results in

Build started 07/04/2014 14:01:05.
Project "C:\MyProj.csproj" on node 1 (default targets).
Build:
Running Publish
_DeploymentUnpublishable:
Skipping unpublishable project.
Done Building Project "C:\MyProj.csproj" (default targets).
Build succeeded.
هل كانت مفيدة؟

المحلول 2

To my surprise it turned out to be McAfee antivirus which is messing up "Publish" here, i was doing things right and it all works fine with McAfee turned off, somehow the antivirus stops the aspnet_compiler.exe to pre-compile the site and as a result the pre-compilation and subsequent merge steps(merge dlls into single assembly) fails, hope no one goes through same pain to find this out.

نصائح أخرى

I'm glad you solved your problem, but I kept ending up here with my own searches, and it definitely wasn't McAfee (or any antivirus software) that was getting in my way. So for anyone else who ends up here, here's what eventually worked for me:

I realized that I was doing /t:Publish instead of /t:Package on the command line. Switching that bypassed the "Skipping unpublishable project" step.

The final command line should look like this (formatted for readability):

MSBuild C:\MyProj.csproj 
   /p:DeployOnBuild=true 
   /p:PublishProfile=WebDeploy 
   /p:CreatePackageOnPublish=True 
   /p:VisualStudioVersion=11.0
   /p:OutputPath="bin\\"
   /t:Package

I had the same problem and the cause was this line in my .csproj:

<OutputType>WinExe</OutputType>

I changed it to be a Case Sensitive match with the rules in Microsoft.Common.targets:

<OutputType>winexe</OutputType>

I it worked!

Using MSBuild.exe command line, you can specify the output path like below: You will explore on c:\Program Files(x86)\MSBuild\14.0\Bin ,Then you run this command:

.\MSBuild.exe [path of your project]/[projectName].csproj /P:Configuration=Release /p:Platform=AnyCPU / p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:outdir="c:\output\\"  /p:VisualStudioVersion=14.0

Please pay attention that you must create the output folder. If you are going to build all projects on solution you have to use below command:

 .\MSBuild.exe [path of your project]/[solutionName].sln /P:Configuration=Release /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:outdir="c:\output\\"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top