question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow specifying environment variables in Exec Task

See original GitHub issue

The Exec Task currently doesn’t allow specifying environment variables which would be set for the to invoked process.

Example use case

The SDK currently defines a Run target which is used by VS to F5 an application. The properties used in the Run target are RunCommand, RunArguments and RunWorkingDirectory: https://github.com/dotnet/sdk/blob/3ed908ee77c592bae787ac78f466c3bc0581970a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L757.

If the Exec Task would allow specifying environment variables we could add a RunEnvironmentVariables property which would remove the need for an extra launchSettings.json file: https://github.com/dotnet/runtime/blob/817ebcaeb617813f98650e78c14e76bbd8b733b0/eng/testing/launchSettings.json#L14-L16.

Other references

cc @rainersigwald

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rainersigwaldcommented, Apr 23, 2020

Exec does support this.

Example from the Mac I’m on right now:

<Project>
  <Target Name="Exec">
    <Exec Command="env | grep FOO"
          EnvironmentVariables="FOO=bar" />
  </Target>
</Project>
$ echo $FOO


$ dotnet msbuild exec-env.proj
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  FOO=bar

@ghogen, I suspect this is an example of the ToolTask-derived task docs not being sufficiently clear that they expose the ToolTask parameters. We have a link in each of them pointing to the base class, but is there a way to define a central snippet that could be included in each doc page?

0reactions
rainersigwaldcommented, Aug 27, 2020

@hairlesshobo would MicrosoftDocs/visualstudio-docs#5783 help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow specifying environment variables in Exec Task #5308
The Exec Task currently doesn't allow specifying environment variables which would be set for the to invoked process.
Read more >
How can I Pass environment to gradle exec
I want to have execute commands using different variables for configurations. In ant, I'd set my properties and then pass them to exec...
Read more >
Exec Task - MSBuild
Learn to use the MSBuild Exec task to run a specified program or command by using the specified arguments.
Read more >
Exec Task
It is possible to specify environment variables to pass to the system command via nested <env> elements. Attribute, Description, Required. key, The name...
Read more >
Environment and Metadata
The --env option on the run/exec/shell commands allows you to specify environment variables as NAME=VALUE pairs: $ apptainer run env.sif Hello $ apptainer ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found