English 中文(简体)
管道 权力 壳牌任务: 意料之外:
原标题:Azure Pipelines PowerShell task -- Unexpected token : in expression or statement

我当时已经到了几个小时。 喜欢的人能够提供帮助。

我有一个称为“dev-env”的变量。 这是评估的内容。 json file for a .NET environment. 我想将这一变量写到管道中的档案中。 这就是说。

www.un.org/Depts/DGACM/index_spanish.htm 顺便说一句,我知道这是一片 ha的解决办法,但是,在我们找到适当把关键过失纳入起步之前,这种解决办法是站不住脚的。 c 档案和确定正确的许可。

现在,我的“灯塔”任务就是这样:

- task: PowerShell@2
  displayName: "Create app settings json files for environments"
  inputs:
    targetType: "inline"
    script: |
      $(dev_env) | ConvertTo-Json -Depth 100 | Out-File $(Build.SourcesDirectory)my-target-folderappsettings.Development.json

然而,我不断在下面的屏幕上发现错误。

“entergraph

我尝试用几乎每一种组合的推测(“”)和“上校”(:)和“后lash”。 我在秘密价值本身和文字中尝试用单一字句来总结整个情况。 我还试图将秘密价值的内容类型改为“申请/json”,但未作改动。

当我把json作为管道变数(而不是AKV秘密)并用单一报价(在实际变值上,而不是在文字上)加以总结时,我能够完成这项任务。 然而,当我对Keter Vaults做同样的事情时,它再次击退了这一错误。

任何人都知道我有多少人失踪?

我的json的Snippet:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}
问题回答

Don t use macro syntax in-line in your scripts -- it s directly inserting the string into your script. So the entire, unescaped JSON file, including newlines, is being inject into the script. Use an env block to pass the value into the script as an environment variable.

i.e.

- task: PowerShell@2
  displayName: "Create app settings json files for environments"
  inputs:
    targetType: "inline"
    script: |
      $env:dev_env | ConvertTo-Json -Depth 100 | Out-File $(Build.SourcesDirectory)my-target-folderappsettings.Development.json
  env: 
    dev_env: $(dev_env)




相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...

热门标签