仅在没有这样的项目时,如何将项目包含在项目组中?
我正在尝试为MS与C ++环境实现一个简单的MSBUILD“插件”。它应该利用一些实用程序,然后将用某些语言写入的文本文件转换为c-sources。
我面临着如何在VS Project中已经存在具有相同名称的文件的情况下,如何将生成的C文件添加到C编译器的输入项目列表中。我正在尝试通过我的.targets
文件中的以下行实现这一目标:
<ItemGroup>
<ClCompile Include="%(MyCompiler.Outputs)" Condition="???" />
</ItemGroup>
但是我不确定如何构成条件零件以达到目标。我尝试过的任何条件都导致正在添加生成的文件,并发出警告:
C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1091,5): warning MSB8027: Two or more files with the name of <FileName>.c will produce outputs to the same location. This can lead to an incorrect build result. The files involved are <FileName>.c, <FileName>.c.
I'm trying to implement a simple MSBuild "plugin" for MS VS C++ environment. It should utilise some utility which, in turn, converts text files written on certain language into C-sources.
And I faced with trouble of how to add the generated C-files dynamically into the C-compiler's input items-list in case of files with the same name already exist in the VS project. I'm trying to achieve this via the following line in my .targets
file:
<ItemGroup>
<ClCompile Include="%(MyCompiler.Outputs)" Condition="???" />
</ItemGroup>
but I'm not sure, how to compose the conditional part to reach the goal. Any conditions I tried lead to that the generated files is being added and VS throws the warning:
C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1091,5): warning MSB8027: Two or more files with the name of <FileName>.c will produce outputs to the same location. This can lead to an incorrect build result. The files involved are <FileName>.c, <FileName>.c.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个
排除
属性,可以排除项目组本身,例如,include
中的项目与dexp exclude
中的项目匹配不会被添加到项目组中。例如:
假设 @(clCompile)由“ AC; BC”和%(MyCompiler.Outputs)组成,由“ CC; AC”组成。上面的代码评估为
“ AC”将不会添加(并重复),因为它在排除集合中。 @(clCompile)的新值将为“ AC; BC; CC”。
There is a
Exclude
attribute and the ItemGroup itself can be excluded, e.g.An item in the
Include
that matches with an item in theExclude
will not be added to the ItemGroup.As an example:
Assume @(ClCompile) consists of "A.c;B.c" and %(MyCompiler.Outputs) consists of "C.c;A.c". The code above evaluates to
"A.c" will not be added (and duplicated) because it is in the Exclude set. The new value of @(ClCompile) will be "A.c;B.c;C.c".