版本控制 CommonAssemblyInfo.cs 和 MSBuild
因此,我有一个 CommonAssemblyInfo.cs 链接到我的解决方案中的所有项目,并由我的 rake/albacore 脚本动态生成,该脚本未签入源代码管理。
我还有一个 CommonAssemblyInfo.cs.local,供没有 ruby 可用时使用,主要供开发人员使用。
是否可以有一个 msbuild 任务或在任何其他项目编译之前运行的任务,在尝试编译我的解决方案之前将 CommonAssemblyInfo.cs.local 复制到 CommonAssemblyInfo.cs ?我讨厌必须有一个命令,您必须了解并键入才能在 Visual Studio 中打开和构建解决方案。
更新 因此,我最终使用批处理文件作为解决方案范围的预构建事件,如下所述:解决方案范围内的预构建事件?,它会检查 CommonAssemblyInfo.cs 是否存在,如果不存在,则仅使用简单的批处理文件将 CommonAssemblyInfo.cs.local 复制到 CommonAssemblyInfo.cs。
So I have a CommonAssemblyInfo.cs linked into all the projects in my solution and is dynamically generated by my rake/albacore scripts which is not checked into source control.
I also have a CommonAssemblyInfo.cs.local for use when there is no ruby available, mainly to be used by devs.
Is it possible to have a msbuild task or something that runs before any of the other project compilation that will copy CommonAssemblyInfo.cs.local to CommonAssemblyInfo.cs before trying to compile my solution? I hate having to have a command you have to just know about and type in order to open and buidl the solution in Visual Studio.
UPDATE
So I ended up using a batch file as a solution wide pre-build event as described here: Solution-wide pre-build event?, it checks to see if CommonAssemblyInfo.cs exists and if not copies CommonAssemblyInfo.cs.local to CommonAssemblyInfo.cs just using a simple batch file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我最终得到的解决方案。
我将解决方案中的每个项目都链接到 CommonAssemblyInfo.cs,它是由我的构建脚本(rake + albacore)自动生成的。
由于我无法将 CommonAssemblyInfo.cs 检查到源代码管理中,因此我创建了一个 CommonAssemblyInfo.cs.local。
简单的解决方案:创建 go.bat,将 CommonAssemblyInfo.cs.local 复制到 CommonAssemblyInfo.cs,开发人员必须在第一次签出项目时运行,然后才能在 VS 中打开解决方案。
纯粹出于政治原因,如果我这样做,人们会对我做“不标准”的事情感到愤怒。复杂的解决方案如下:
我在解决方案中创建了一个名为 PreBuild 的项目,解决方案中的每个项目都依赖于该项目。这迫使构建顺序首先构建该项目。该项目包含一个预构建事件,该事件调用以下批处理文件:
因此,现在任何选择将头埋在沙子里的开发人员都可以签出该项目,并在 VS 中愉快地打开它,而不会意识到任何构建脚本的存在。
This is the solution I ended up with.
I have each project in the solution link to a CommonAssemblyInfo.cs which is automagically generated for me by my build scripts (rake + albacore).
Since I cannot check CommonAssemblyInfo.cs into source control, I create a CommonAssemblyInfo.cs.local.
Simple solution: create go.bat which copies CommonAssemblyInfo.cs.local to CommonAssemblyInfo.cs that devs must run the first time they check out the project before opening the solution in VS.
For purely political reasons, if I did this people would have had hissy fits about me doing "nonstandard" things. Complex solution follows:
I created a project in the solution called PreBuild which every project in the solution depends on. This forces the build order to be such that this project is built first. This project contains a pre-build event which calls the following batch file:
So now any developers who choose to keep their heads in the sand may checkout the project and blissfully open it up in VS unaware that any build scripts exist at all.
你说的是在VS IDE中编译,还是通过team build编译?如果您正在谈论团队构建,那么您可以使用“AfterGet”事件作为使用标准“复制”msbuild 任务的地方。如果您正在谈论 VS IDE,那么您仍然可以使用“复制”msbuild 任务。
Are you talking about compilation in the VS IDE, or compilation through team build? If you are talking about team build, then you can use the "AfterGet" event as a place to use the standard "copy" msbuild task. If you are talking about the VS IDE, then you can still use the "copy" msbuild task.