VSTS构建不提取dacpac文件(云中托管的代理) [英] VSTS build doesn't pickup the dacpac file (hosted agent in cloud)

查看:100
本文介绍了VSTS构建不提取dacpac文件(云中托管的代理)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VSTS部署到我的数据库中,问题出在以下步骤之一:我需要拾取dacpac文件并将其部署到Azure SQL服务器,但失败: 在此步骤中,我使用Microsoft在VSTS中提供的"执行Azure SQL:DacpacTask ". 有一个文件可以做到这一点,叫做" DACPAC文件",文档说要这样使用它:

I'm trying to use VSTS to deploy into my database, the problem is in one of the steps I need to pick up the dacpac file and deploy it to the Azure SQL server but it fails: in that step, I'm using "Execute Azure SQL: DacpacTask" which is provided by Microsoft in VSTS. there is a filed to do it which is called "DACPAC File" and the documentation said to use it like this:

$(agent.releaseDirectory)\ AdventureWorksLT.dacpac

$(agent.releaseDirectory)\AdventureWorksLT.dacpac

但是它给了我以下错误:

but it gave me the below error:

未找到要使用搜索模式部署的文件 d:\ a \ 1 \ s \ $(agent.releaseDirectory)\ AdventureWorksLT.dacpac

No files were found to deploy with search pattern d:\a\1\s\$(agent.releaseDirectory)\AdventureWorksLT.dacpac

所以我作弊,并在其中添加了以下值:

so I did a cheating and put the below value in it:

d:\ a \ 1 \ s \ AdventureWorksLT.dacpac

d:\a\1\s\AdventureWorksLT.dacpac

它确实可以工作,但是显然,它永远不会工作,因为我需要使用环境变量,例如:

it does work but obviously, it won't work forever as I need to use an environment variable, something like :

$(agent.releaseDirectory)\ AdventureWorksLT.dacpac

$(agent.releaseDirectory)\AdventureWorksLT.dacpac

有什么建议吗?

推荐答案

我遇到了同样的问题.我找不到详细的文档,但是通过试验,发现了这一点.

I've had this same problem. I wasn't able to find detailed documentation, but from experimenting, this is what I found.

我假设您的DACPAC是作为构建解决方案"任务的一部分创建的.构建完成并创建DACPAC后,它存在于$(System.DefaultWorkingDirectory)目录的子文件夹中.

I'm assuming that your DACPAC is created as part of a Build Solution task. After the build completes and the DACPAC is created, it exists in a sub-folder of the $(System.DefaultWorkingDirectory) directory.

显然,Azure SQL数据库部署任务无法访问$(System.DefaultWorkingDirectory)文件夹.因此,必须将文件复制到可以访问的位置.所以这就是我所做的:

Apparently, the Azure SQL Database Deployment task cannot access the $(System.DefaultWorkingDirectory) folder. So the file must be copied somewhere where it can be accessed. So here's what I did:

  1. Visual Studio Build任务将构建解决方案,包括DACPAC.生成的DACPAC放置在$(System.DefaultWorkingDirectory)子文件夹中.
  2. 添加复制文件"任务作为下一步.源文件夹属性应为"$(System.DefaultWorkingDirectory)". Contents属性应为"**/YourDacPacFilename.dacpac".目标文件夹应为$(build.artifactstagingdirectory). "**/"告诉VSTS在所有子文件夹中搜索匹配的文件.
  3. 添加Azure SQL数据库部署任务以部署实际的DACPAC. DACPAC文件将位于$(build.artifactstaging目录)中.

这篇关于VSTS构建不提取dacpac文件(云中托管的代理)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆