使用NAnt中的ASP编译器构建ASP .Net MVC应用程序(Using the ASP Compiler in NAnt to build an ASP .Net MVC application)

我使用ASP编译器成功地在NAnt中构建ASP .Net应用程序,没有任何问题。作为我的持续集成过程的一部分。

但是,如果我在ASP .NET MVC应用程序上尝试完全相同的过程,则构建在NAnt中失败,但将在Visual Studio中成功编译。 我在NAnt中得到的错误消息是:

[HttpParseException]:无法加载类型'MyNamespace.Views.Home.Index'

看起来它在文件名中有点问题,但我可能是错的。

任何建议是最受欢迎的。

I am succesfully building ASP .Net applications in NAnt using the ASP Compiler, without a problem., as part of my Continuous Integration process.

However, if I try exactly the same process on an ASP .NET MVC application, the build fails in NAnt, but will compile succesfully in Visual Studio. The error message I get in NAnt is:

[HttpParseException]: Could not load type 'MyNamespace.Views.Home.Index'

which appears that it has a problem with the dots in the filenames, but I might be wrong.

Any suggestions are most welcome.

最满意答案

在使用aspnet_compile之前,需要将MVC应用程序构建为项目。 如果您的MVC项目使用其他类库项目,则还需要进行编译。

运行aspnet_compile之后,我们希望删除不应该成为部署站点一部分的各种文件。

此构建文件位于项目MvcApplication的父目录中。

<project default="build"> <property name="build.dir" value="${project::get-base-directory()}"/> <property name="build.config" value="Release" /> <target name="build"> <exec program="${framework::get-framework-directory('net-3.5')}/msbuild.exe"> <arg value="/property:Configuration=${build.config}" /> <arg value="${build.dir}/MvcApplication/MvcApplication.csproj" /> </exec> <delete dir="${build.dir}/PrecompiledWeb" includeemptydirs="true" failonerror="false"/> <exec program="${framework::get-framework-directory('net-2.0')}/aspnet_compiler.exe"> <arg value="-v" /> <arg value="/" /> <arg value="-p" /> <arg value="MvcApplication/" /> <arg value="-f" /> <arg value="PrecompiledWeb" /> </exec> <delete verbose="true" includeemptydirs="true" failonerror="false"> <fileset basedir="${build.dir}/PrecompiledWeb"> <include name="Controllers" /> <include name="Properties" /> <include name="obj/**" /> <include name="obj" /> <include name="*.csproj" /> <include name="*.csproj.user" /> </fileset> </delete> </target> </project>

The MVC app needs to be built as a project before using aspnet_compile. If your MVC project uses other class library projects, they also need to be compiled.

After running aspnet_compile, we then want to delete various files that should not be part of the deployed site.

This build file is located in the parent directory to my project MvcApplication.

<project default="build"> <property name="build.dir" value="${project::get-base-directory()}"/> <property name="build.config" value="Release" /> <target name="build"> <exec program="${framework::get-framework-directory('net-3.5')}/msbuild.exe"> <arg value="/property:Configuration=${build.config}" /> <arg value="${build.dir}/MvcApplication/MvcApplication.csproj" /> </exec> <delete dir="${build.dir}/PrecompiledWeb" includeemptydirs="true" failonerror="false"/> <exec program="${framework::get-framework-directory('net-2.0')}/aspnet_compiler.exe"> <arg value="-v" /> <arg value="/" /> <arg value="-p" /> <arg value="MvcApplication/" /> <arg value="-f" /> <arg value="PrecompiledWeb" /> </exec> <delete verbose="true" includeemptydirs="true" failonerror="false"> <fileset basedir="${build.dir}/PrecompiledWeb"> <include name="Controllers" /> <include name="Properties" /> <include name="obj/**" /> <include name="obj" /> <include name="*.csproj" /> <include name="*.csproj.user" /> </fileset> </delete> </target> </project>

更多推荐

NAnt,ASP,HttpParseException,电脑培训,计算机培训,IT培训"/> <meta name="d