如何让 Subversion 处理自动生成的文件?
我将 ASP.NET Web 部署项目与 TortoiseSVN 和 VisualSVN 结合使用,但这是有关 Subversion 中生成的文件的常见问题。
Web 部署项目会自动生成网站的并行“部署”版本,其中所有代码都会被剥离并编译到单个程序集中。 我的文件结构是:
- Trunk
- Trunk/MyProject(网站根目录)
- Trunk/MyProject_deploy(部署项目根目录)
- Trunk/MyProject_deploy/Release (部署网站根目录,自动生成)
问题如下:MyProject_deploy/Release 在构建时重新生成(在发布模式下)。 该目录被删除并重新创建,因此我丢失了所有 .svn 元数据; 当我提交时,我得到状态“阻塞”,我已经查找过该状态,这意味着有一个非托管本地文件夹与服务器上的托管文件夹同名。
(我可以忽略 Release 文件夹,但我想直接从 Subversion 服务器进行 FTP 部署。)
在 Subversion 中处理自动生成的文件的最佳方法是什么?
I'm using ASP.NET Web Deployment Projects with TortoiseSVN and VisualSVN, but this is a general question about generated files in Subversion.
A Web Deployment Project automatically generates a parallel "deployment" version of your website with all code stripped out and compiled into a single assembly. My file structure is:
- Trunk
- Trunk/MyProject (website root)
- Trunk/MyProject_deploy (deployment project root)
- Trunk/MyProject_deploy/Release (deployment website root, automatically generated)
Here's the problem: MyProject_deploy/Release is regenerated on build (in Release mode). The directory is deleted and re-created, so I lose all the .svn metadata; and when I go to commit, I get status "Obstructed", which I've looked up and means that there's an unmanaged local folder with the same name as a managed folder on the server.
(I could just ignore the Release folder, but I want to do FTP deploy directly from the Subversion server.)
What's the best way to deal with auto-generated files in Subversion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
设置 svn:ignore 属性。 不要将它们添加到您的版本控制系统中。 构建过程生成的任何内容都不属于那里。 真正属于那里的是完成构建过程所需的东西。
我建议添加一个像 CruiseControl.NET 这样的持续集成服务器 - 它可以从源代码构建项目,然后从中进行部署。 这将使您能够使用 2 个最佳实践而不是 1 个,并且仍然可以解决您的问题。
Set the svn:ignore property. Don't add them to your version control system. Anything generated by the build process doesn't belong there. What does belong there are the things needed to complete the build process.
I'd recommend adding a continuous integragion server like CruiseControl.NET to the mix - it can build the project from the source, and then do the deploy from that. This will put you in the position of using 2 best practices instead of 1, and still solve your problem.
如果您使用的是 Visual Studio,您是否可以定义构建前和构建后事件,以在构建之前将 .svn 目录(或多个目录)移出 Release,然后再移回?
If you're using Visual Studio, could you define pre and post-build events to move the .svn directory (or directories) out of Release before your build, and then back in afterward?
使用安装项目创建 Windows Installer 输出时,这也是一个问题。
一种选择是更改输出文件名,以便将生成的文件转储到部署项目根目录中,而不是名为“Release”的子文件夹中。
对于安装项目,我生成了一个 MSI 文件,并且效果很好 - 没有删除/重新创建文件夹,因此没有 SVN 错误,并且它很干净,部署项目根文件夹中只有两个文件。
This is also a problem when using Setup projects to create Windows Installer output.
One option is to change the Output file name so that the generated files are dumped in your deployment project root, rather than in a sub-folder called "Release".
In the case of the Setup project, I was generating a single MSI file and this worked well - no folders are being deleted/re-created so no SVN errors, and it is clean with only two files in the deployment project root folder.