David Smit
David Smit

Reputation: 839

MSBUILD script building solution, but not deploying publishing profile

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

Upvotes: 0

Views: 3166

Answers (2)

David Smit
David Smit

Reputation: 839

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.

Upvotes: 1

Sayed Ibrahim Hashimi
Sayed Ibrahim Hashimi

Reputation: 44322

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

Upvotes: 2

Related Questions