0

I have created a publishing profile for my web page, and I can successfully publish using the web deploy interface in Visual Studio (right click project, deploy etc). It builds the project on my local PC, and copies the files across to destination IIS server.

But now I am trying to create a MSBuild command, which should do the same, but it is only building the solution, not copying it across to the server.

My MSbuild command looks like this, and I run it from the solution source directory

msbuild "test.co.za.sln" p:DeployOnBuild=true /p:PublishProfile="test.co.za"  /p:UserName="domain\test"  /p:Password="test"

Is there anything wrong with my build command? As you can see in the screenshot, it is building successfully, but no files are being copied across. Which makes me wonder if the publishing profile is executed at all. I have tried various combinations of publishprofile paths, full paths, with extensions, without, nothing seems to copy my files accross.

enter image description here

My publishing profile looks like this App_Data\Publishprofile\test.co.za.pubxml

<?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <WebPublishMethod>MSDeploy</WebPublishMethod>
        <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
        <SiteUrlToLaunchAfterPublish>http://test.co.za</SiteUrlToLaunchAfterPublish>
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <MSDeployServiceURL>test.co.za</MSDeployServiceURL>
        <DeployIisAppPath>test.co.za</DeployIisAppPath>
        <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
        <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
        <UserName>domain\test</UserName>
        <_SavePWD>True</_SavePWD>
      </PropertyGroup>
    </Project>

EDIT: This is an existing classic ASP website which I added to a solution, it doesn't contain a ".csproj" file, just a "website.publishproj", which doesn't seem to execute

David Smit
  • 829
  • 1
  • 13
  • 31

2 Answers2

2

It doesn't look like you are passing in the VisualStudioVersion property. You should include that. The value will either be 11.0, 12.0, or 14.0 based on the version of Visual Studio you are using. You should likely pass in a value for Configuration as well but it's not required. I've blogged about why this is important at http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx.

You can find the docs for asp.net command line publishing at http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment

Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178
  • Thanks @Sayed for your response! I am a great fan of your blog! I tried both VisualStudioVersion and Configuration but didn't work. I forgot to mention, this is an existing ASP classic website I added to my solution, it doesn't contain a ".csproj" file. So a different question: Can I deploy a website from a msbuild command script, where the site isn't bound to a project file? (I only have a website.publishproj) I created a demo C# project, and could successfully publish with script. But not when adding it as an "existing website" – David Smit Jun 23 '14 at 10:51
  • I think my question might be the same as this one http://stackoverflow.com/questions/14395487/publish-profile-not-working-when-building-website-project . Not sure if that is the correct solution though – David Smit Jun 23 '14 at 12:06
1

Looks like my "website.publishingproj" is never being built when I run the msbuild command. Not sure why, @Sayed do you perhaps know?

I had to create a targets file next to my solution called "after.solutionName.sln.targets" and copy the code from this answer : https://stackoverflow.com/a/15138373/1184603

<!--?xml version="1.0" encoding="utf-8"?-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="Deploy Website" AfterTargets="Build">
        <Message Text="Starting Website deployment" Importance="high">
        </Message>
        <MSBuild Projects="$(MSBuildProjectDirectory)\MyWebs\website.publishproj" 
        BuildInParallel="true" /> 
    </Target>
</Project>

It now publishes correctly from my msbuild script.

Community
  • 1
  • 1
David Smit
  • 829
  • 1
  • 13
  • 31