如何获得aspnet_compiler从Visual Studio生成过程中调用? [英] How to get aspnet_compiler invoked from Visual Studio during build?

查看:198
本文介绍了如何获得aspnet_compiler从Visual Studio生成过程中调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想Visual Studio中被用作Azure的Web角色的有效载荷 precompile我的ASP.NET应用程序 。所以,我发现这个帖子解释如何打电话aspnet_compiler验证意见。

I want Visual Studio to precompile my ASP.NET application which is used as an Azure web role payload. So I've found this post that explains how to call aspnet_compiler to validate views.

我试着以下内容添加到生成后事件我的ASP.NET应用程序的:

I tried to add the following to "post-build event" of my ASP.NET application:

call "%VS100COMNTOOLS%\vsvars32.bat"
aspnet_compiler -v / -p $(ProjectDir)

或替代本(应用程序名称显式指定):

or alternatively this (application name specified explicitly):

call "%VS100COMNTOOLS%\vsvars32.bat"
aspnet_compiler -v /ASP.NET-Application-ProjectNameHere -p $(ProjectDir)

在这两种情况下,当构建运行我看到下面的生成输出:

In both cases when the build runs I see the following in the build output:

Setting environment for using Microsoft Visual Studio 2010 x86 tools.
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.

和显然不是precompilation是因为如果我改变任何的.aspx或.cshtml文件建设行动,以无它不会对Azure的服务包和看法不再打开,一旦包部署到Azure上。

and clearly no precompilation happens because if I change any .aspx or .cshtml file "Build Action" to "None" it doesn't get to the Azure service package and the view no longer opens once the package is deployed to Azure.

如何在Visual Studio中做我的设置aspnet_compiler为precompiling?

How do I setup aspnet_compiler for precompiling from within Visual Studio?

推荐答案

如果你想使用Asp.NET编译您的Visual Studio中/ MSBuild的话可以加   AspNetCompiler 任务到你的项目文件(.csproj / .vbproj),并设置 MvcBuildViews

If you want to use Asp.NET Compiler within your Visual Studio / msbuild then you can add AspNetCompiler Task to your project file (.csproj/.vbproj) and set MvcBuildViews to true.

例如:

<Project>
  <PropertyGroup>
    <MvcBuildViews>true</MvcBuildViews>
  </PropertyGroup>
  <!-- ... -->
  <Target Name="PrecompileWeb" AfterTargets="build" Condition="'$(MvcBuildViews)'=='true'">
    <Message Text="Starting AspNetCompiler for $(ProjectDir)" Importance="high" />
    <AspNetCompiler
        VirtualPath="temp"
        PhysicalPath="$(WebProjectOutputDir)"
        Force="true"
    />
  </Target>
  <!-- ... -->
</Project>

您也可以设置 TARGETPATH​​ 属性来指定目标目录。

You may also set TargetPath attribute to specify destination directory.

AfterTargets =构建类似于生成后事件。请参见目标建立更多的订单

AfterTargets="build" is similar to "post-build event". See Target Build Order for more.

这篇关于如何获得aspnet_compiler从Visual Studio生成过程中调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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