msbuild - how to modify environment variable for the entire build - msbuild

I want to modify the environment variable for all Exec tasks.
This answer seems to imply that it's not possible to do that and a 2011 blog says outright that it's not possible to change the environment per Exec task . . . so does that mean that it's not possible even to set the environment variable for ALL Exec tasks globally?
Is this possible? If yes, how do I do it?

Related

How can I make sure that a scalardl environment works properly after setting up or modifying the environment?

I have a question about Scalar DL.
How can I make sure that a scalardl environment works properly after setting up or modifying the environment?
You can use a read-only contract if you have one in your applications or you can use Scalar DL Explorer otherwise.
https://github.com/scalar-labs/scalardl-tools/tree/master/explorer

Bamboo custom deployment-project variables

In Bamboo, I want so take a build-release and deploy it on a target host. The target host should be variable.
As far as I know, it is not possible to run deployment-projects with customized deployment-variables (as it is possible to override plan-variables on custom-builds). My question is: is that true and if yes, what is the best way to achieve what I want?
Here are some thoughts I had during research regarding this issue:
I could use a plan-variable "host" in my build job and always customize it as needed. Then I write this variable into a file that will be declared as a build-artifact. In my deployment-tasks I use the "Inject Bamboo variables configuration" task to get the variable. This solution has the disadvantage, that I always have to run a build, even if the artifacts do not change.
Global variables are not feasible because they are not build-dependent. Therefore I can not use them for my task. The reason is that it could happen that they get overwritten by another build.
Are there any better solutions/thoughts on this task?
target host should be variable
No, each host is a separate environment. Otherwise the notion of "promoting an environment" breaks apart. This may be a lot of work to implement and therefore I strongly advise using bamboo specs (in Java).
it is not possible to run deployment-projects with customized deployment-variables
I confirm: it's not possible. And again, it would break the notion of environment promotion. Rule of thumb: your environment setup should be immutable: no variable variance. The only difference b/n runs is the artifacts that are to be deployed.
You can set variables in 'Other environment settings' in deployment project while configuring Environment. This way you will not have to run build when artifacts don't change. Just change variable value before deploying the artifact.

How do I set the RUST_TEST_TASKS environment variable?

I am attempting to write tests for my Rust program. Normally, these tests are run in parallel but I want to run them sequentially. I looked around and I can set this environment variable RUST_TEST_TASKS=1, but I am not sure where to do that.
The environment variable is actually RUST_TEST_THREADS
I think what they mean is setting the environment variables in the shell the test runner is running in, such as:
RUST_TEST_TASKS=1 ./my-test-runner
or exporting it:
export RUST_TEST_TASKS=1
./my-test-runner

How to put variables in IntelliJ's run configuration?

Say I have a variable named repo_path and I want to set some environmental variables or VM options based on this variable, such as SOME_VAR={$repo_path}/some_sub_path or -DsomeProperty={$repo_path} so that I don't have to type repo_path every time I use it. What is the correct way to achieve this other than typing the full address everywhere?
Why don't you define a regular system variable 'REPO_PATH' and use it in IntelliJ Run Configuration as a regular system variable :)
-DsomeProperty=$REPO_PATH
It works well under Mac OS, so I assume it will work under Ubuntu as well.

MSBuild failing to expand environment variables

I'm pretty new to MSBuild, so I might be doing something obviously-wrong, but a colleague of mine who's worked with MSBuild a lot can't see any error, so I figured I'd post here and see if anyone else can see it.
I'm converting an old batch file that we used to call ant to MSBuild tasks (because we want to call it from MSBuild) and the environment variables always expand to )for reasons we don't understand.
I have a property group that includes
<PropertyGroup>
<EnvJavaHome>
$([System.Environment]::GetEnvironmentVariable("JAVA_HOME"))
</EnvJavaHome>
<!-- ... -->
</PropertyGroup>
(line breaks added for legibility). Now the MSBuild Property Functions reference suggests I'm calling System.Environment.GetEnvironmentVariable correctly, but I always get a value of ). The code works perfectly well when I hardcode the value, however.
What obvious thing am I missing? :o)
If it's an env variable, you should be able to just use it like $(JAVA_HOME)
as in <EnvJavaHome>$(JAVA_HOME)</EnvJavaHome> , see e.g. use http://msdn.microsoft.com/en-us/library/ms171459(v=VS.100).aspx
(Check that the environment variable actually exists though, echo %JAVA_HOME% in a command window)