使用MSBuild从网站构建中排除文件夹

编程入门 行业动态 更新时间:2024-10-24 08:22:41
本文介绍了使用MSBuild从网站构建中排除文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们使用MSBuild通过CruiseControl构建我们的解决方案.作为解决方案的一部分,我们有多个程序集和一个网站.通过VS2008构建,构建成功.但是,在生成框上,我们收到以下错误.

We use MSBuild to build our solutions through CruiseControl. We have several assemblies and a website as part of the solution. Building through VS2008 the build is successful. However on the build box we get the following error.

ASPNETCOMPILER (,): errorASPCONFIG: The CodeDom provider type "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" could not be located.

这样做的原因是,在网站的scripts文件夹中,我们有几个扩展名为.java的文件.我们不希望构建这些文件.确实,在构建的scripts文件夹中我们不需要任何东西.

The reason for this is that in the scripts folder of the website we have a couple files with the .java extension. We don't want these files built. And really we don't need anything in the scripts folder built.

是否可以从网站项目中排除构建文件夹或扩展名的方法?还是让MSBuild遵循VS2008用来决定编译内容的相同规则?

Is there a way to exclude a folder or an extension from being built within a website project? Or tell MSBuild to follow the same rules VS2008 is using to decide what to compile?

推荐答案

您可以使用项目元素(在MSDN上的简要介绍).

例如,如果您有这样定义的项目:

You can remove whole folders with Remove attribute of Item element (brief introduction on MSDN).

For example, if you have items defined like this:

<ItemGroup> ... <Compile Include="Tests\Test1.cs" /> <Compile Include="Tests\SubTests\SubTest1.cs" /> ... </ItemGroup>

,并且要从"Tests"文件夹中排除所有类,可以在项目结束时定义一个任务:

and you want to exclude all classes from "Tests" folder, you can define a task at the end of your project:

... <PropertyGroup> <CoreCompileDependsOn>$(CoreCompileDependsOn);ExcludeTestsFolder</CoreCompileDependsOn> </PropertyGroup> <Target Name="ExcludeTestsFolder"> <ItemGroup> <Compile Remove="Tests\**\*.cs" /> </ItemGroup> </Target> </Project>

在外部文件中定义此类任务并使用导入元素(在另一个线程中进行了详尽的解释).

It's also a good idea to define such a task in an external file and import it with Import element (thorough explanation in another thread).

更多推荐

使用MSBuild从网站构建中排除文件夹

本文发布于:2023-11-16 17:00:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606162.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   网站   MSBuild

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!