小编Jar*_*red的帖子

使用MSBuild更新C++资源文件中的FILEVERSION会导致编译失败

我的任务是使用msbuild自动化我们的构建过程.我们有大约20个Visual C++项目和20个C#项目,这使得编辑所有版本字符串变得很麻烦.我们的版本号在构建时是生成的,因此我们需要在命令行上将完整版本字符串作为属性传递.

我的初始实现使用MSBuild扩展包File任务来替换.rcAssemblyInfo.cs文件.

<FileSystem.File TaskAction="Replace" Files="@(AssemblyInfoFiles)" RegexPattern='\[assembly: AssemblyVersion\(".*"\)\]' Replacement='[assembly: AssemblyVersion("$(Version)")]'/>
<FileSystem.File TaskAction="Replace" Files="@(AssemblyInfoFiles)" RegexPattern='\[assembly: AssemblyFileVersion\(".*"\)\]' Replacement='[assembly: AssemblyFileVersion("$(Version)")]'/>
<FileSystem.File TaskAction="Replace" Files="@(RCFiles)" RegexPattern="FILEVERSION\s+\S+" Replacement="FILEVERSION $(Version)"/>
<FileSystem.File TaskAction="Replace" Files="@(RCFiles)" RegexPattern="PRODUCTVERSION\s+\S+" Replacement="PRODUCTVERSION $(Version)"/>
<FileSystem.File TaskAction="Replace" Files="@(RCFiles)" RegexPattern='VALUE\s+"FileVersion",\s*".*"' Replacement='VALUE "FileVersion", "$(Version)"'/>
<FileSystem.File TaskAction="Replace" Files="@(RCFiles)" RegexPattern='VALUE\s+"ProductVersion",\s*".*"' Replacement='VALUE "ProductVersion", "$(Version)"'/>
Run Code Online (Sandbox Code Playgroud)

这在AssemblyInfo.cs文件上工作得很好,但是当我编译任何C++项目时,我得到如下错误:

.\MyProject.rc(23): error RC2135: file not found: 0x09
.\MyProject.rc(71): error RC2135: file not found: 1
.\MyProject.rc(72): error RC2135: file not found: 6
.\MyProject.rc(73): error RC2135: file not …
Run Code Online (Sandbox Code Playgroud)

msbuild resources visual-c++

7
推荐指数
1
解决办法
5980
查看次数

标签 统计

msbuild ×1

resources ×1

visual-c++ ×1