从MSBuild项目获取输出文件文件、项目、MSBuild

由网友(我爱的人和爱我的人*)分享简介:是否有可能从一个MSBuild项目获得列表中的所有所有的输出文件?Is it possible to obtain a list all all the output files from a MSBuild project?在一个简单的项目,我可以做类似In a simple project, I could...

是否有可能从一个MSBuild项目获得列表中的所有所有的输出文件?

Is it possible to obtain a list all all the output files from a MSBuild project?

在一个简单的项目,我可以做类似

In a simple project, I could do something like

<CreateItem Include="$(OutputDir)***">
      <Output ItemName="AllOutputs" TaskParameter="Include"/>
</CreateItem>

但我的项目是一个更大的构建的一部分,和所有输出到一个共同的位置,我希望能够exculde DLL和内容不属于。

but my projects are part of a larger build, and all outputs go to a common location, I want to be able to exculde dlls and content that don't belong.

任何想法?

推荐答案

在看着你的意见,我再次意识到我错intre preTED你真正需要的。这是一个有趣的问题,你有你的手。

After looking at your comment again I realized that I mis-intrepreted what you really needed. This is an interesting problem you have on your hands.

如果你不介意编辑项目文件本身可能能够得到pretty的关闭以你想要的。有一个项目的 FileWrites 来跟踪所有被在生成过程中写出来的文件。要开始使用此编辑玩弄项目文件中有这样的 AfterBuild 目标

If you don't mind editing the project file itself you may be able to get pretty close to what you want. There is an item FileWrites that keeps track of all the files that were written out during the build process. To start playing around with this edit the project file to have this AfterBuild target

<Target Name="AfterBuild">
  <Message Text="FileWrites: @(FileWrites)" Importance="high"/>
</Target>

有一些问题,这种做法以及

There are some problems with this approach as well

您必须编辑项目文件本身 这将包含写入中间输出目录的文件(即 OBJ 的)和输出目录(即斌的) 如果有建立自定义,他们不需要写此文件 You have to edit the project file itself This will contain files written to the intermediate output dir (i.e. obj) and the output dir (i.e. bin) If there are build customizations, they are not required to write to this item

您可能会认为你可以解决与的MSBuild的第一个问题:查找许多项目引用技术,输出FileWrites项目做一个构建之后。这如果包装凸出文件放在同一个文件夹中原来的项目本身,因为全部的.csproj文件里面的物品都与相对路径声明才有效。所以有去,对于大部分

You might think that you could solve the first problem with the MSBuild: Find Many Project References technique and output the FileWrites item after doing a build. This will only work if the wrapper proj file was placed in the same folder as the original project itself because all the items inside of a .csproj file are declared with a relative path. So there goes that for the most part.

您可以通过使用FindUnderPath任务只能得到安置在 OutputPath 文件夹中的文件得到了第二个限制。

You can get over the second limitation by using the FindUnderPath task to only get the files placed in the OutputPath folder.

您可以做什么,但不是真正可靠的要么是再次检查OutputPath在构建的开头,然后在构建NAD的看看到底发生了什么补充道。比方说,你把原来的文件到一个项目的开始文件,并在构建年底把所有的文件放到一个项目名为EndFiles你可以做的:

What you could do but is not really reliable either is to examine the OutputPath at the begining of the build and then once again at the end of the build nad see what was added. Let's say that you put the original files into an item StartFiles and at the end of the build put all the files into an item named EndFiles you could the do:

<Target Name="SomeTargetHere">

<ItemGroup>
    <FilesWritten Include="@(EndFiles)" />
    <FilesWritten Remove="@(StartFiles)"/>
</ItemGroup>

<!-- Now FilesWritten contains the difference between EndFiles & StartFiles -->

</Target>

总之我不知道,如果有不涉及任何自定义任务或自定义记录一个很好的解决方案:(

In short I'm not sure if there is a good solution that doesn't involve either a custom task or a custom logger :(.

阅读全文

相关推荐

最新文章