I have a Visual Studio 2010 MVC2 web application that I'm building via the command line using Hudson. I'd like to make Hudson publish a web output, so I added the DeployOnBuild=true and CreatePackageOnPublish=True tags to my command line.
My command is:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /target:Clean,Build /property:Configuration=Debug;DeployOnBuild=True;CreatePackageOnPublish=True; [my project name.csproj]
Running this command on my development machine (Windows 7) successfully publishes a web output to \obj\Debug\Package\PackageTmp\
. But running it on the Hudson server (WS 2008) compiles successfully, but it doesn't publish. Same command, same version of MSBuild, same source code.
I've tried the /t:Publish
target, which gives me a Skipping Unpublishable Project response, as I've seen on several other people's posts.
I've tried adding the DeployOnBuild=True
and CreatePackageOnPublish=True
tags to my project file as well, and no change.
Any thoughts on why this isn't publishing? Am I using these tags incorrectly? I'm sure there's something here that I'm just not seeing.
MSBuild supports targeting a single project while building the solution. You do this by putting the project name in the Target parameter. Note that this is the visual name of the project you specify in the solution (not necessarily the same as the name of the . csproj file).
The DeployOnBuild=true property essentially means "I want to execute an additional target when build completes successfully." The DeployTarget property identifies the name of the target you want to execute when the DeployOnBuild property is equal to true.
The publish profiles created with Visual Studio can be used with MSBuild and Visual Studio. For instructions on publishing to Azure, see Publish an ASP.NET Core app to Azure with Visual Studio. The dotnet new mvc command produces a project file containing the following root-level <Project> element: XML Copy.
Assuming you do not have Visual Studio 2010 installed on your hudson server, then it may be that you are missing the publishing "targets" file. After a lot of head-to-desk banging, I finally solved this.
For quite a while I have known that I needed to copy the directory
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications
from my local machine with VS2010 to my server in order to get the project to build. But to get the project to also publish I needed to also copy over the directory
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web
Note: In my case I am actually committing those folders to my source control and changing the <MSBuildExtensionsPath32>
value in my csproj file to point to these checked out folders (so there is one less step when prepping a server). This isn't necessary to get it to work, but you may want to consider this after you solve your issue.
UPDATE: So after I did the above, the build complained that it could not find "Microsoft.Web.Deployment.dll". To solve this I needed to install Microsoft Web Deploy v2.0 on the server even though I am only publishing to the file system. I guess I can see the logic in this.
UPDATE: I have discovered that installing "Visual Studio 2010 Shell (Integrated)" through the IIS Web Platform Installer will install the required build targets. This seems like a nice compromise between not having the entire Visual Studio application installed on your server and not manually copying seemingly arbitrary folders to your server from your dev machine.
It seems that conditions to run publish target are not satisfied.
1) You can have different publication paths
2) Condition to run publish target is false
To verify both of them call your command with flag /v:diag. Search by Target "Publish" and try to figure out what really happens. It will looks like
Target "ExecuteT4Templates: (TargetId:144)" in file "D:\App\App.csproj" from project "D:\App\App.csproj": Skipping target "ExecuteT4Templates" because all output files are up-to-date with respect to the input files. Input files: D:\App\App.exe\\App_Config\Configuration.tt;D:\App\App.exe\\App_Config\Debug.App.tt;obj\\Debug.t4lastbuild Output files: D:\App\App.exe\\App.config Done building target "ExecuteT4Templates" in project "App.csproj".: (TargetId:144)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With