Msbuild just produces a package but does not deploy it when using a publish profile. Why?
Asked Answered
T

2

11

MSBuild really seems to like me. Recently I am trying out the different possibilities to build and deploy from command line. However I am experiencing some seemingly strange behaviour when I pass a publish profile to MSBuild.

Here is an example of what I just did:

I deploy to a local IIS for the moment with a command such as this:

msbuild D:\PathToFile\DeployDBVariation01\DeployDBVariation01\DeployDBVariation01.csproj
    /p:Configuration=Release;
    Platform=AnyCpu;
    DeployOnBuild=true;
    DeployTarget=MSDeployPublish;
    MSDeployServiceURL="localhost";
    DeployIisAppPath="DeployApp/DeployThis";
    MSDeployPublishMethod=InProc;
    Username=thisIsNotActuallyMyUsername;
    password=guesswhat;
    AllowUntrustedCertificate=true

And this works! After that it is successfully deployed and I can call it in a browser.

However, since Visual Studio gives us the comfort of using publishing profiles I wanted to try that in conjunction with MSBuild over command line and tried the following command:

msbuild D:\PathToFile\DeployDBVariation01\DeployDBVariation01\DeployDBVariation01.csproj
    /p:DeployOnBuild=true;
    AllowUntrustedCertificate=true;
    PublishProfile=ReleaseLocal

ReleaseLocal is a profile I created in Visual Studio and it looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>localhost</MSDeployServiceURL>
    <DeployIisAppPath>DeployApp/DeployThis</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>InProc</MSDeployPublishMethod>
    <EnableMSDeployBackup>False</EnableMSDeployBackup>
    <UserName />
    <_SavePWD>False</_SavePWD>
    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="DefaultConnection" Order="1" Enabled="False">
          <Destination Path="Data Source=.\SQLEXPRESS;Initial Catalog=HorstDataProductive;User ID=sa;Password=GuessWhat" />
          <Object Type="DbDacFx">
            <PreSource Path="Data Source=.\SQLEXPRESS;Initial Catalog=HorstData;User ID=sa;Password=GuessWhat" includeData="False" />
            <Source Path="$(IntermediateOutputPath)AutoScripts\DefaultConnection_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
          </Object>
          <UpdateFrom Type="Web.Config">
            <Source MatchValue="Data Source=.\SQLEXPRESS;Initial Catalog=HorstData;User ID=sa;Password=GuessWhat" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
          </UpdateFrom>
        </ObjectGroup>
      </Objects>
    </PublishDatabaseSettings>
  </PropertyGroup>
  <ItemGroup>
    <MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String">
      <ParameterValue>Data Source=.\SQLEXPRESS;Initial Catalog=HorstDataProductive;User ID=sa;Password=GuessWhat</ParameterValue>
    </MSDeployParameterValue>
  </ItemGroup>
</Project>

As you can see I have some additional connection string replacement there that I want to test.

So I execute that last MSBuild-command that I have shown you and it executes without any errors. Instead it says that the web deployment task was successful and that a package has been created in a certain path. Now that is actually the right package. When I import that manually in my IIS it is the result I expect, also the connection string replacement has been done.

But I do not understand why it actually is just creating the package but not deploying it in one run, like in my first command.

Can someone explain? (Or even better, what do I have to do to make it also deploy that package immediately)

Tumbrel answered 17/5, 2013 at 11:58 Comment(0)
A
9

You need to specify the VS version.

http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment

msbuild /P:DeployOnBuild=True /P:VisualStudioVersion=11.0 /P:PublishProfile=Dev.pubxml

Don't forget to allow untrusted certs if you're using a 'fake' internal certificate

Abukir answered 4/6, 2013 at 13:27 Comment(2)
fyi.../P:VisualStudioVersion=11.0 applies to VS2012Abukir
that seems to do it, thanks for the input, currently though I am running into some other errors when trying this out, I will come back here later to update on the question/answerTumbrel
I
1

Looks like you're missing the deploy target.. it's got all the necessary info, but doesn't know what you want it to do. Try this;

msbuild D:\PathToFile\DeployDBVariation01\DeployDBVariation01\DeployDBVariation01.csproj /p:DeployOnBuild=true;DeployTarget=MSDeployPublish;AllowUntrustedCertificate=true;PublishProfile=ReleaseLocal

Intellectual answered 28/5, 2013 at 14:21 Comment(3)
I have the same issue, my website deployment is producing a package but not a published website, The command used is msbuild C:\Test.csproj /p:DeployOnBuild=true /p:PublishProfile=Test /p:VisualStudioVersion=10.0Kendrick
Try adding DeployTarget=MSDeployPublish;Intellectual
the option DeployTarget=MSDeployPublish disables use if publish profileCephalization

© 2022 - 2024 — McMap. All rights reserved.