如何使用 aspnet_compiler 处理排除的文件?

发布于 2024-10-20 20:23:31 字数 413 浏览 6 评论 0原文

我正在尝试使用 aspnet_compiler 将已编译的项目从一个位置移动到另一个位置。我正在使用 Subversion 进行版本控制。

该过程基本上从 subversion 中获取所有代码,进行构建,然后调用 aspnet_compiler。

当我有一个排除的 ascx 文件时,我的问题就出现了。该文件是最新代码的一部分,但正常的构建编译器会忽略它,所以没有麻烦。然而,Aspnet_compiler 会崩溃,因为它找不到该特定控件的隐藏代码。

我不确定

  • 我这样做是否正确;
  • 有一种方法可以从 Subversion 获取正确的文件树
  • 有一种更简单的方法;或者
  • 这是预期的,我每次都需要删除排除的文件。

我将不胜感激任何帮助。

汤姆

I'm trying to use aspnet_compiler to move a project that has already compiled from one location to another. I'm using Subversion for revision control.

The process basically gets all the code out of subversion, does a build, then calls aspnet_compiler.

My problem comes into being when I've got an excluded ascx file. This file is part of the latest code, but the normal build compiler ignores it, so no trouble. Aspnet_compiler blows up, however, because it cannot find the code behind for that particular control.

I'm not sure if

  • I'm doing this right;
  • there's a way to just get the correct file tree from Subversion
  • There's an easier way; or
  • this is expected, and I need to delete excluded files every time.

I'd appreciate any help.

Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

尴尬癌患者 2024-10-27 20:23:31

从 .NET 4.5 或 4.5.1(我不确定是哪一个)开始,aspnet_compiler.exe 中添加了一个 -x 选项,它允许您从编译中排除目录。您可以通过命令“aspnet_compiler /?”找到该选项。

-x            The virtual path of a directory that should be excluded from precompilation.
This switch can be used multiple times.

示例:

我的网站中有一个名为“ToBeExcluded”的文件夹。我可以使用以下命令来预编译网站并排除该文件夹,

aspnet_compiler -v /foo -p "C:\MyWebsite" -x ToBeExcluded "c:\temp\web"

Since .NET 4.5 or 4.5.1 (I am not sure which) there was a -x option added to aspnet_compiler.exe which allows you to exclude directories from compilation. You can find the option through command "aspnet_compiler /?".

-x            The virtual path of a directory that should be excluded from precompilation.
This switch can be used multiple times.

Example:

There is a folder named "ToBeExcluded" in my website. I can use the following command to pre-compile the website and exclude that folder,

aspnet_compiler -v /foo -p "C:\MyWebsite" -x ToBeExcluded "c:\temp\web"
违心° 2024-10-27 20:23:31

这是预期的:Aspnet_compiler.exe 编译应用程序中的所有文件,并且不查看项目文件。因此,它没有任何排除文件的概念。

Babak Naffas 删除文件的建议可能是处理文件的最简单方法,而不是每次都手动删除它(或编写删除脚本)。

This is expected: Aspnet_compiler.exe compiles all files in the application and does not look at the project file. Thus, it does not have any notion of an excluded file.

Babak Naffas's suggestion of deleting the file is probably the easiest way of dealing with the file, rather than manually deleting it (or scripting its deletion) each time.

菊凝晚露 2024-10-27 20:23:31

我为此挣扎了很长时间。但最终找到了解决方法

attrib +h folderToExclude & runAspComplierWithAllOptions & attrib -h folderToExclude

隐藏文件夹 ->编译->显示文件夹。

I was struggling for so long with this. But finally found an workaround

attrib +h folderToExclude & runAspComplierWithAllOptions & attrib -h folderToExclude

Hide folder -> compile -> show folder.

撩心不撩汉 2024-10-27 20:23:31

有一个非常简单的方法:将隐藏属性设置为要排除的文件夹,aspnet_compiler 将跳过它。

此错误的典型情况是由 npm install 创建的 node_modules 文件夹

如果您从脚本或命令行运行 npm install,您可以在运行 nmp install 后运行 attrib 命令来隐藏该文件夹:

attrib +H node_modules

如果您从 msbuildnpm install code> 项目,您可以添加一个 exec 任务,如下所示:

<PropertyGroup>
    <HideFolder>attrib +H "$(PackageJsonFolder)\node_modules"</HideFolder>
</PropertyGroup>
<!-- next line is for debugging, remove it when finished -->
<Warning Text="Hide node_modules command: '$(HideFolder)'"/>
<Exec Command="$(HideFolder)">

attrib 命令的退出代码始终为零,至少在我的测试中如此,因此检查没有意义它来确定命令是否成功运行。

在前面的 msbuild 示例中,要隐藏的文件夹是 "$(PackageJsonFolder)\node_modules",因为属性 PackageJsonFolder 是所在文件夹的名称packages.json 文件,因此将在其中创建 node_modules

对于其他情况,您始终可以指定相对于项目位置的文件夹,如下所示:

<HideFolder>attrib +H "$(MSBuildProjectDirectory)\folder\to\hide"</HideFolder>

并使用与上一个示例中相同的石灰运行命令。

There is a very easy way to do it: set the hidden attribute to the folder to exclude, and aspnet_compiler will skip it.

A typical case for this error is the node_modules folder created by npm install

If you run npm install from a script, or from the command line, you can run the attrib command, after running nmp install to hide the folder:

attrib +H node_modules

If you run npm install from a msbuild project, you can add an exec task, like this:

<PropertyGroup>
    <HideFolder>attrib +H "$(PackageJsonFolder)\node_modules"</HideFolder>
</PropertyGroup>
<!-- next line is for debugging, remove it when finished -->
<Warning Text="Hide node_modules command: '$(HideFolder)'"/>
<Exec Command="$(HideFolder)">

The exitcode for attrib command is always zero, at least in my tests, so it makes no sense to check it to determine if the command run successfully.

In the previous msbuild example the folder to hide is "$(PackageJsonFolder)\node_modules" because the property PackageJsonFolder is the name of the folder where packages.json file is, and thus where node_modules will be created.

For other cases you can always specify your folder relative to the project's location, like this:

<HideFolder>attrib +H "$(MSBuildProjectDirectory)\folder\to\hide"</HideFolder>

and run the command using the same lime in the previous example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文