I have a project where there are files in a particular non-standard textual format. When these files are touched/modified, I want to run a certain custom compiler on them to generate XML, which is part of the output of the whole solution.
我有一个项目,其中有特定非标准文本格式的文件。当触摸/修改这些文件时,我想在它们上运行某个自定义编译器来生成XML,这是整个解决方案输出的一部分。
I'm considering creating a MSBuild task to do this. It will take as input the non-stadard file names and output the requisite XML files. The task will then be used in the other projects in the solution.
我正在考虑创建一个MSBuild任务来执行此操作。它将输入非stadard文件名并输出必需的XML文件。然后,该任务将用于解决方案中的其他项目。
I want new developers on this project to have minimal setup. That means, I want to be able to take a clean copy of my solution directly from source control and have the build first build the custom task, then apply it as necessary to the other projects in the class.
我希望这个项目的新开发人员能够进行最少的设置。这意味着,我希望能够直接从源代码控制中获取我的解决方案的干净副本,并让构建首先构建自定义任务,然后根据需要将其应用于类中的其他项目。
I'm concerned that the build output of the project that builds the custom task needs to copy its output assembly to some known location so that the other projects can refer to it. What is the proper way of going about doing this?
我担心构建自定义任务的项目的构建输出需要将其输出程序集复制到某个已知位置,以便其他项目可以引用它。这样做的正确方法是什么?
1 个解决方案
#1
You're about to walk into a mess here, because Visual Studio is going to lock the custom task Assembly when it's first used, thereby causing any further builds in Visual Studio (i.e. Build > Solution) to fail.
你将要陷入混乱,因为Visual Studio将在首次使用时锁定自定义任务程序集,从而导致Visual Studio中的任何进一步构建(即Build> Solution)失败。
As @stijn commented, you should override the Build target and use another method of building the assembly with the custom task, e.g. using the Csc task or spawning another MSBuild.exe process (see answer to linked question).
正如@stijn所评论的那样,您应该覆盖Build目标并使用另一种使用自定义任务构建程序集的方法,例如:使用Csc任务或生成另一个MSBuild.exe进程(请参阅链接问题的答案)。
The way I decided to go though was to create a separate solution, e.g. "Build Tools", containing the custom task assembly (among other tools), and required that it be built before anything else. I personally find the notion of checking-in prebuilt binaries of this source very unpalatable. If developers didn't want to build the Build Tools solution, they would copy the output from some nightly build.
我决定采用的方法是创建一个单独的解决方案,例如“构建工具”,包含自定义任务程序集(以及其他工具),并要求在其他任何工具之前构建它。我个人觉得这个来源的登记预建二进制文件的概念非常难吃。如果开发人员不想构建Build Tools解决方案,他们会复制一些每晚构建的输出。
Unfortunately there isn't an easy way of getting around "hardcoding" a known (relative) location. Using $(SolutionDir)
usually works - just not if you try to run MSBuild on the project directly, instead of the solution (VS is a bit more intelligent when you open a project by itself).
不幸的是,没有一种简单的方法来解决“硬编码”已知(相对)位置的问题。使用$(SolutionDir)通常可以正常工作 - 如果您尝试直接在项目上运行MSBuild而不是解决方案(当您单独打开项目时,VS会更加智能化)。
#1
You're about to walk into a mess here, because Visual Studio is going to lock the custom task Assembly when it's first used, thereby causing any further builds in Visual Studio (i.e. Build > Solution) to fail.
你将要陷入混乱,因为Visual Studio将在首次使用时锁定自定义任务程序集,从而导致Visual Studio中的任何进一步构建(即Build> Solution)失败。
As @stijn commented, you should override the Build target and use another method of building the assembly with the custom task, e.g. using the Csc task or spawning another MSBuild.exe process (see answer to linked question).
正如@stijn所评论的那样,您应该覆盖Build目标并使用另一种使用自定义任务构建程序集的方法,例如:使用Csc任务或生成另一个MSBuild.exe进程(请参阅链接问题的答案)。
The way I decided to go though was to create a separate solution, e.g. "Build Tools", containing the custom task assembly (among other tools), and required that it be built before anything else. I personally find the notion of checking-in prebuilt binaries of this source very unpalatable. If developers didn't want to build the Build Tools solution, they would copy the output from some nightly build.
我决定采用的方法是创建一个单独的解决方案,例如“构建工具”,包含自定义任务程序集(以及其他工具),并要求在其他任何工具之前构建它。我个人觉得这个来源的登记预建二进制文件的概念非常难吃。如果开发人员不想构建Build Tools解决方案,他们会复制一些每晚构建的输出。
Unfortunately there isn't an easy way of getting around "hardcoding" a known (relative) location. Using $(SolutionDir)
usually works - just not if you try to run MSBuild on the project directly, instead of the solution (VS is a bit more intelligent when you open a project by itself).
不幸的是,没有一种简单的方法来解决“硬编码”已知(相对)位置的问题。使用$(SolutionDir)通常可以正常工作 - 如果您尝试直接在项目上运行MSBuild而不是解决方案(当您单独打开项目时,VS会更加智能化)。