TeamCity不会在没有app.config的情况下构建类库

时间:2016-12-09 14:25:00

标签: c# configuration teamcity

所以我有一个项目(一个非常简单的类库),我正在构建。该库对外部资源进行一些调用,这取决于特定的连接字符串。我已将此连接字符串放在app.config文件中。

但是,出于密钥安全性的原因,我不希望将此app.config文件放在源代码管理中,因此该文件已被忽略'。

不幸的是,当TeamCity尝试构建库时,它会抱怨它Could not copy the file "App.config" because it was not found.项目确实在我的开发环境中构建和执行单元测试。

我确定我已经掌握了基本想法(将字符串放在文件中,而不是将该文件放入源代码控制中),但我认为我已经错过了一些关于如何这应该设置。

我使用TeamCity构建此库有哪些选项?

1 个答案:

答案 0 :(得分:0)

这是一个可行的解决方案:

在团队城市中创建新的PowerShell构建步骤 将以下powershell代码复制到构建步骤中,并将新构建步骤设置为在MSBuild步骤之前执行。

## first, set the directory to the place where the file lives
Set-Location %teamcity.build.checkoutDir%\RecordingProvider\RecordingProvider

## copy the existing template file into a real app.config file
Copy-Item App.template.config -destination App.config

If (Test-Path App.config){
  ##File exists
  Write-Output "App.config exists"
  exit 0
}Else{
  ## File does not exist
  Write-Error "App.config does not exist!!"
  exit -1
} 

就像那样,TeamCity现在编译构建。

我希望还有一些其他的解决方案,但这会让我感觉到,直到我看到它们。