简体   繁体   English

msbuild 构建和发布 ASP.NET MVC 应用程序

[英]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.在我们的解决方案中,我们有几个项目:ASP.NET MVC 上的类库、控制台应用程序和 webbaps。 I'd like to publish console and web apps to directory.我想将控制台和网络应用程序发布到目录。 For console apps msbuild works like a charm.对于控制台应用程序 msbuild 就像一个魅力。 The worst part is with ASP.NET MVC applications.最糟糕的部分是 ASP.NET MVC 应用程序。 There are only dll's on the output directory.输出目录上只有dll。 I tried build and deploy with PublishProfile property, but it doesn't help.我尝试使用 PublishProfile 属性构建和部署,但没有帮助。 Interestingly, everything is ok when I publish this profile on VS.有趣的是,当我在 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.我读了一些关于 msdeploy 的内容,但对我来说似乎不是解决方案。

How can I publish ASP.NET MVC application from console, like in VS?如何从控制台发布 ASP.NET MVC 应用程序,就像在 VS 中一样?

Please try to use C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe .请尝试使用C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe And this is the official version which contains all vs environment variables.这是包含所有 vs 环境变量的正式版本。

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.但是C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe来自framework sdk,只能做一些简单的构建操作,不能处理大型复杂的构建。

So you should use:所以你应该使用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM