Tommy
Tommy

Reputation: 63

msbuild build and publish ASP.NET MVC application

In our solution we have few projects: class libraries, console apps and webbaps on ASP.NET MVC. I'd like to publish console and web apps to directory. For console apps msbuild works like a charm. The worst part is with ASP.NET MVC applications. There are only dll's on the output directory. I tried build and deploy with PublishProfile property, but it doesn't help. Interestingly, everything is ok when I publish this profile on VS.

I think, I tried everything, but it didn't work. For example:

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" C:\test\TestSol.sln /t:Apps\Webapp /p:DeployOnBuild=true /p:PublishProfile="Properties\PublishProfiles\Directory.pubxml" /p:VisualStudioVersion=14.0

My profile:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>..\..\deploy</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
  </PropertyGroup>
</Project>

I read something about msdeploy, but it didn't seems like solution for me.

How can I publish ASP.NET MVC application from console, like in VS?

Upvotes: 1

Views: 636

Answers (1)

Mr Qian
Mr Qian

Reputation: 23818

Please try to use C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe. And this is the official version which contains all vs environment variables.

However, C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe is from framework sdk and can only do some simple build operations, cannot handle large and complex builds.

So you should use:

 C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe

Upvotes: 1

Related Questions