Question, Bug, or Feature?
Type: Feature
Enter Task Name: .NET Core
list here (V# not needed):
https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/DotNetCoreCLIV2
Currently if one needs to supply environment variable to the .NET Core task they need to use a script task. It is very common that the dotnet test command needs environment variables to better configure the test. The current way to provide environment variable is not good enough, as it capitalizes every variable, and that makes it impossible to use that as configuration that is not uppercase for a .NET Core service (using .NET Core configuration).
The way to fix this is to simply allow for environment variables to be specified, as it is currently possible on the script task.
If you need more information please let me know.
You can create a powershell inline script and define the variable as:
$env:variable = "value1"
@internetgdl Not on the azure-pipelines.yaml DotNetCoreCLIV2 task, you can't. This variable on a previous script would not survive for the next task.
I stumbled over the same problem. Finally I found out that environment variables can be assigned to any task. See the pseudo schema for the tasks here: https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#task
@giggio , this means simply add env: with the desired vars on the same indent as the task.
Is this new? Ok, this solves my problem.
Not sure, when this came in, I am pretty new to this ;-). Happy to hear that it solves your problem :-).
I stumbled over the same problem. Finally I found out that environment variables can be assigned to any task. See the pseudo schema for the tasks here: https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#task
@giggio , this means simply addenv:with the desired vars on the same indent as the task.
Is there a way to do this for classic pipelines?
Could you share the exact Yaml syntax?
Doesn't like mine...
- task: DotNetCoreCLI@2
enabled: true
displayName: 'Run GremlinApp'
inputs:
command: 'run'
projects: './GremlinApp/GremlinApp.csproj'
workingDirectory: './GremlinApp'
env: AUTHKEY KEY
This works:
yaml
- task: DotNetCoreCLI@2
inputs:
command: test
projects: "tests/**/*Tests.csproj"
env:
foo: 1
bar: 2
Most helpful comment
This works:
yaml - task: DotNetCoreCLI@2 inputs: command: test projects: "tests/**/*Tests.csproj" env: foo: 1 bar: 2