VS2010 DB项目部署错误SQL01268目录查找失败

发布于 2024-09-17 18:30:05 字数 1051 浏览 13 评论 0原文

我的 VS2010 数据库部署在安装了 SQL Server 2008 R2 的构建服务器上失败。这是相关的输出:

正在创建 Acme.Database...

D:\TeamCity\BuildAgent\Work\da2fc5ebd5805d44\src\Acme.Database\sql\Acme.Database.sql(30,0):错误 SQL01268:.Net SqlClient 数据提供程序:消息 5133,级别 16,状态 1 ,第 1 行文件“C:\Program Files\Microsoft SQL Server**MSSQL10.MSSQLSERVER**\MSSQL\DATA\Acme_Database_log.ldf”的目录查找失败,出现操作系统错误 3(系统找不到指定的路径。 )。

D:\TeamCity\BuildAgent\Work\da2fc5ebd5805d44\src\Acme.Database\sql\Acme.Database.sql(30,0):错误 SQL01268:.Net SqlClient 数据提供程序:消息 1802,级别 16,状态 1 ,第 1 行创建数据库失败。无法创建列出的某些文件名。检查相关错误。

执行批处理时发生错误。

实际路径在这里:

C:\Program Files\Microsoft SQL Server**MSSQL10_50.MSSQLSERVER**\MSSQL\DATA\Acme_Database.mdf

我在数据库项目中可以找到的唯一路径引用位于根文件夹中,该文件名为:

PRIMARY.Acme_Database.sqlfile.sql

它包含一个 ALTER DATABASE 语句,我将其更改为使用 _50 路径,但这并没有解决问题。

我不确定为什么 db 项目在任何情况下都需要知道实际数据库 MDF 文件所在的位置 - 我本以为它可以通过 TSQL 连接到它,但无论如何我无法让项目部署出现此错误,希望得到任何帮助。

My VS2010 database deploy is failing on my build server, which has SQL Server 2008 R2 installed on it. Here's the output that's relevant:

Creating Acme.Database...

D:\TeamCity\BuildAgent\Work\da2fc5ebd5805d44\src\Acme.Database\sql\Acme.Database.sql(30,0): Error SQL01268: .Net SqlClient Data Provider: Msg 5133, Level 16, State 1, Line 1 Directory lookup for the file "C:\Program Files\Microsoft SQL Server**MSSQL10.MSSQLSERVER**\MSSQL\DATA\Acme_Database_log.ldf" failed with the operating system error 3(The system cannot find the path specified.).

D:\TeamCity\BuildAgent\Work\da2fc5ebd5805d44\src\Acme.Database\sql\Acme.Database.sql(30,0): Error SQL01268: .Net SqlClient Data Provider: Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

An error occurred while the batch was being executed.

The actual path is here:

C:\Program Files\Microsoft SQL Server**MSSQL10_50.MSSQLSERVER**\MSSQL\DATA\Acme_Database.mdf

The only reference to the path I could find in the database project was in the root folder, a file called:

PRIMARY.Acme_Database.sqlfile.sql

It includes an ALTER DATABASE statement that I changed to use the _50 path, but this did not fix the issue.

I'm not sure why the db project needs to know where the actual database MDF file is located in any case - I would have thought it could just connect to it vis TSQL, but in any case I can't get the project to deploy with this error and would appreciate any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

眼睛会笑 2024-09-24 18:30:05

事实证明,如果您在架构对象\数据库级对象\存储\文件中指定“文件”(使用“添加项目”、“文件”),则路径中指定的值将覆盖从服务器查找的值。如果必须指定它们,请使用 sqlcmdvariables $(DefaultdataPath)$(Databasename) 中的变量来填写内容。

Turns out if you specify a "file" in Schema Objects\Database Level Objects\Storage\Files (use Add Item, File) the values specified in the path override those looked up from the Server. If you must specify them use the variables from sqlcmdvariables $(DefaultdataPath)$(Databasename) to fill things out.

探春 2024-09-24 18:30:05

查看服务器本身的默认文件路径。

截屏:http://screencast.com/t/OWM5ODFjZj

事实上,您不'指定的路径可能是问题所在。

[更新]
我建议这样做的原因是,在创建部署脚本的过程中,如果您没有在Project Settings -> 中指定设置,在“部署”选项卡中,从目标服务器的路径查找 DefaultDataPath。

Take a look at the default file path on the server itself.

Screencast: http://screencast.com/t/OWM5ODFjZj

The fact that you don't have a path specified could likely be the issue.

[Update]
The reason I suggest this is that during the creation of the deployment script, if you have not specified the settings in the Project Settings -> Deployment tab, the DefaultDataPath is looked up from the target server's path.

我是男神闪亮亮 2024-09-24 18:30:05

我对 TeamCity 一无所知,所以这可能是一个愚蠢的问题,但是您是如何进行部署的?看起来数据库项目的 MSBuild 部署任务可以采用提供数据路径的属性:

http://www.codewrecks.com/blog/index.php/2009/10/06/deploy-a-database-project- with-tfs-build/

可以这样设置路径吗?

I don't know anything about TeamCity really so this may be a stupid question, but how are you doing the deployment? It looks like the MSBuild deploy task for a DB project can take a property that gives the data path:

http://www.codewrecks.com/blog/index.php/2009/10/06/deploy-a-database-project-with-tfs-build/

Can you set the path that way?

盛夏已如深秋| 2024-09-24 18:30:05

我有同样的错误,但有不同的解决方案。
对我来说,一切都是正确的(据我所知),但生成的部署脚本在数据库名称变量之前设置了路径变量 - 导致对不存在的变量的引用。我更新了 Database.sqlcmdvars 以对数据库名称值进行硬编码 - 这不是最佳实践,但足以满足我的需求。

I had the same error, but a different solution.
For me everything was correct (as far as I can tell), but the generated deploy script set the path variables before the databasename variable - resulting in a reference to a variable that did not exist. I updated Database.sqlcmdvars to hardcode the database name value - not best practice, but a sufficient workaround for my needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文