VS 自定义构建步骤中的自动版本文件
我想在自定义构建步骤(预构建)中做两件事,但我的批处理文件技能至少可以说有点生疏,所以我在弄清楚它时遇到了一些麻烦!
我需要:
- 查找所有资源文件并将版本更新为 1.0.[CustomDateFormat].[BuildOfday]
- 将此版本号复制到 HTML 文件中
我是否必须编写一个单独的程序来执行此操作,然后从自定义构建过程运行它或还有别的办法吗?
另外,如果我要使用单独的程序,我将如何传递有关解决方案中加载的项目的信息(这样我就不会对恰好位于同一目录中的不相关项目进行版本控制)?
I want to do two things in a custom build step (pre build) but my batch file skills are a little rusty to say the least so am having a little trouble figuring it out!
I need to:
- Find all resource files and update the version to 1.0.[CustomDateFormat].[BuildOfday]
- Copy this version number into a HTML file
Will I have to write a separate program to do this then run it from the custom build process or is there another way?
Also, if I were to use a separate program how would I pass in information about the projects loaded in the solution (so I don't go off versioning unrelated projects that happen to be in the same directory)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 PowerShell 进行文件操作。
查找资源文件的最简单方法是通过项目目录(使用
$(ProjectDir)
宏)。但是,如果你确实遇到这样的情况,即同一个文件夹中有多个项目,那么你将很难确定哪些资源文件属于哪个项目。我的第一个建议是将项目拆分到它们自己的文件夹中。如果这不是选项(您知道可以添加文件作为链接?),也许您的PowerShell脚本可以根据项目名称找到资源文件。否则我没有比手动解析 .csproj 文件更好的主意了。
I'd recommend using PowerShell for file manipulation.
The easiest way to find resource files is by project directory (use
$(ProjectDir)
macro). However, if you really have such a situation, where you have several projects in the same folder, you will have problems to figure out which resource files belong to which project. My first recommendation would be to split projects into their own folders.If that's not option (do you know that it's possible to add file as a link?), maybe your PowerShell script can find resource files based on project name. Otherwise I don't have a better idea than manually parsing .csproj file.