如何使用 aspnet_compiler 处理排除的文件?
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从 .NET 4.5 或 4.5.1(我不确定是哪一个)开始,aspnet_compiler.exe 中添加了一个 -x 选项,它允许您从编译中排除目录。您可以通过命令“aspnet_compiler /?”找到该选项。
示例:
我的网站中有一个名为“ToBeExcluded”的文件夹。我可以使用以下命令来预编译网站并排除该文件夹,
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 /?".
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.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.
我为此挣扎了很长时间。但最终找到了解决方法
隐藏文件夹 ->编译->显示文件夹。
I was struggling for so long with this. But finally found an workaround
Hide folder -> compile -> show folder.
有一个非常简单的方法:将隐藏属性设置为要排除的文件夹,
aspnet_compiler
将跳过它。此错误的典型情况是由
npm install
创建的node_modules
文件夹如果您从脚本或命令行运行
npm install
,您可以在运行nmp install
后运行attrib
命令来隐藏该文件夹:如果您从
msbuildnpm install
code> 项目,您可以添加一个exec
任务,如下所示:attrib
命令的退出代码始终为零,至少在我的测试中如此,因此检查没有意义它来确定命令是否成功运行。在前面的
msbuild
示例中,要隐藏的文件夹是"$(PackageJsonFolder)\node_modules"
,因为属性PackageJsonFolder
是所在文件夹的名称packages.json
文件,因此将在其中创建node_modules
。对于其他情况,您始终可以指定相对于项目位置的文件夹,如下所示:
并使用与上一个示例中相同的石灰运行命令。
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 bynpm install
If you run
npm install
from a script, or from the command line, you can run theattrib
command, after runningnmp install
to hide the folder:If you run
npm install
from amsbuild
project, you can add anexec
task, like this: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 propertyPackageJsonFolder
is the name of the folder wherepackages.json
file is, and thus wherenode_modules
will be created.For other cases you can always specify your folder relative to the project's location, like this:
and run the command using the same lime in the previous example.