VisualStudio SQL 数据库项目 sqlcmdvars TFS 部署覆盖自定义文件路径?
我在 VisualStudio 2010 中使用 TFS 2010 进行源代码控制,有一个 SQL 数据库项目,其中有几个分支,每个分支根据配置文件部署到不同的服务器。
使用 sqlcmdvars 文件,并在每个配置文件的文件名中附加配置文件(Debug.sqlcmdvars 等),让我可以通过使用 mdf 文件的保留名称 Path1 和 Path2 来指定特定部署环境的唯一文件路径和日志文件。
<?xml version="1.0" encoding="utf-8"?>
<SqlCommandVariables xmlns="urn:Microsoft.VisualStudio.Data.Schema.Package.SqlCmdVars">
<Version>1.0</Version>
<Properties>
<Property>
<PropertyName>Path1</PropertyName>
<PropertyValue>C:\SQLSERVER LOG\$(DatabaseName)\</PropertyValue>
</Property>
<Property>
<PropertyName>Path2</PropertyName>
<PropertyValue>C:\SQLSERVER DATA\$(DatabaseName)\</PropertyValue>
</Property>
</Properties>
</SqlCommandVariables>
现在我正在尝试添加具有关联 FileStream FileGroup 的自定义 FileStream 文件
我添加了一个附加条目在 sqlcmdvars 文件中:
<Property>
<PropertyName>PathBlobStream</PropertyName>
<PropertyValue>C:\SQLSERVER DATA\$(DatabaseName)\BlobStream\</PropertyValue>
</Property>
但我不确定如何告诉数据库在 SchemaObjects\Database Level Objects\Storage\BlobStore.sqlfile.sql 声明的内容上使用此属性:
ALTER DATABASE [$(DatabaseName)]
ADD FILE (NAME = [BlobStore], FILENAME = 'C:\SQLSERVER DATA\####\BlobStream') TO FILEGROUP [BlobStreamFileGroup];
如何在sqlcmdvars 覆盖新 FileStream 文件的路径?
I have an SQL database project in VisualStudio 2010 in source control with TFS 2010 with a few branches that each deploy to different servers depending on the configuration profile.
Using a sqlcmdvars file with the configuration profile appended in the filename (Debug.sqlcmdvars, etc..) for each configuration profile lets me specify the unique file path for a particular deployment environment by use of the reserved names Path1 and Path2 for the mdf file and the log file.
<?xml version="1.0" encoding="utf-8"?>
<SqlCommandVariables xmlns="urn:Microsoft.VisualStudio.Data.Schema.Package.SqlCmdVars">
<Version>1.0</Version>
<Properties>
<Property>
<PropertyName>Path1</PropertyName>
<PropertyValue>C:\SQLSERVER LOG\$(DatabaseName)\</PropertyValue>
</Property>
<Property>
<PropertyName>Path2</PropertyName>
<PropertyValue>C:\SQLSERVER DATA\$(DatabaseName)\</PropertyValue>
</Property>
</Properties>
</SqlCommandVariables>
Now I'm trying to add a custom FileStream file with an associated FileStream FileGroup
I have added an additional entry in sqlcmdvars files:
<Property>
<PropertyName>PathBlobStream</PropertyName>
<PropertyValue>C:\SQLSERVER DATA\$(DatabaseName)\BlobStream\</PropertyValue>
</Property>
But am not sure how to tell the database to use this over what the SchemaObjects\Database Level Objects\Storage\BlobStore.sqlfile.sql has declared:
ALTER DATABASE [$(DatabaseName)]
ADD FILE (NAME = [BlobStore], FILENAME = 'C:\SQLSERVER DATA\####\BlobStream') TO FILEGROUP [BlobStreamFileGroup];
How do you use the new entry in the sqlcmdvars to override the path for the new FileStream file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现执行此操作的最佳方法是在 dbproj 文件中添加其他条目,以根据配置文件使用不同的架构文件:
关键是复制/粘贴原始架构文件并在文件名中附加配置配置文件名称。这会将调试变体保留为原始文件名,以便将来的任何模式比较都不会注意到其他变体。您希望在源代码管理中包含其他架构文件,但如果遵循上述条目,它们将不会显示在项目中。我验证了 MSBuild 可以正确处理此问题。我祈祷 TFS 也会做同样的事情。
The best way I found to do this was add additional entries in the dbproj file to use a different schema file depending on the configuration profile:
The key was copy/pasting the original schema file and appending the configuration profile name in the file name. This keeps the debug variation with the original file name so that any future schema comparisons will be oblivious to the additional variations. You want to include the additional schema files in source control, but if following suite to the entries above, they won't show up in the project. I verified MSBuild handles this correctly. I'm crossing my fingers that TFS will do the same.