我如何编译使用的MSBuild一个ASP.Net MVC项目 [英] How do I compile an ASP.Net MVC project using MSBuild

查看:136
本文介绍了我如何编译使用的MSBuild一个ASP.Net MVC项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用的MSBuild编译一个ASP.Net MVC项目?我们使用持续集成服务器编译和部署我们的应用程序。为了简单起见,我创建了一个VS2008 MVC 1.0项目。我立即创建一个MSBuild脚本文件进行编译。我没有在项目更改任何code。该脚本的MSBuild包含以下的目标。


 < AspNetCompiler
      VirtualPath =/
       PhysicalPath =C:\\开发\\ MVC1 \\
        TARGETPATH​​ =C:\\发布\\ XXX
        力=真
        调试=假
 可更新=真


该MVC项目SLN文件包含在c:\\研发\\ MVC1 \\目录下。我运行XP /专业版。

我收到一个错误ASPCONFIG:它是使用注册为allowDefintion ='MachineToApplication超越应用水平的节是错误..我删除了authenication模式,会员供应商等来自网络配置文件,直到我终于看到了不同的错误消息。我现在收到一条错误信息说文件'/views/shared/site.master'不存在。

这是怎么回事?预先感谢您的帮助!

我是使用了错误的MSBuild命令?


解决方案

如果您编译SLN文件(的MSBuild mysolution.sln)或

 <项目的MSBuild =的MSBuild mysolution.sln目标=重建ContinueOnError =假
StopOnFirstFailure =FALSE/><! - -d -errorstack - >

和SLN-文件的ASP.NET MVC项目的.csproj文件则.csproj的文件确实有你需要的一切。用记事本打开的.csproj和寻找:

1),这应该是真实的:

 < MvcBuildViews>假LT; / MvcBuildViews>

2)目标名称=AfterBuildCompiler

 <目标名称=AfterBuildCompiler条件='$(MvcBuildViews)'=='真'>
    < AspNetCompiler VirtualPath =SomeVirtualDirPhysicalPath =C:\\开发\\ MVC1 \\TARGETPATH​​ =C:\\发布\\ XXX \\/>
  < /目标>

我没有做任何事情,它的工作。我实际上是由我的配置,以便只发布版本部署应用程序(通过移动下PropertyGroups MvcBuildViews属性,然后我可以使用相同的.csproj在研发(调试)和部署(释放)。

How do I compile an ASP.Net MVC project using MSBuild? We use a Continuous Integration server to compile and deploy our applications. To keep things simple I created an MVC 1.0 project in VS2008. I immediately created an MSBuild script file to compile it. I did not change any code in the project. The MSBuild script contained the following target.

   <AspNetCompiler
      VirtualPath="/"
       PhysicalPath="C:\Development\mvc1\"
        TargetPath="c:\publish\xxx"
        Force="true"
        Debug="false" 
 Updateable="true"

The MVC project sln file is contained in the c:\development\mvc1\ directory. I am running XP/Pro.

I am receiving an error ASPCONFIG: it is an error to use a section registered as allowDefintion='MachineToApplication' beyond application level.. I removed the authenication mode, membership provider, etc. from the web config file until I finally saw a different error message. I am now receiving an error message saying that the file '/views/shared/site.master' does not exist.

What is going on? Thanks in advance for your help!

Am I using the wrong MSBuild command?

解决方案

If you compile your sln-file (msbuild mysolution.sln) or

<MSBuild Projects="msbuild mysolution.sln" Targets="Rebuild" ContinueOnError="false"
StopOnFirstFailure="false" /><!-- -d -errorstack -->

and the sln-file has the ASP.NET MVC-project .csproj-file then the .csproj-file does have everything you need. Open the .csproj with notepad and look for:

1) This should be true:

<MvcBuildViews>false</MvcBuildViews>

2) Target Name="AfterBuildCompiler":

  <Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="SomeVirtualDir" PhysicalPath="C:\Development\mvc1\" TargetPath="c:\publish\xxx\" />
  </Target>

I didn't do anything else and it worked. I actually made my config so that only release build deploy the application (by moving MvcBuildViews-property under PropertyGroups. Then I can use the same .csproj in the development (debug) and deployment (release).

这篇关于我如何编译使用的MSBuild一个ASP.Net MVC项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆