Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Setting Environment Variables prior to build

$
0
0

Setting variables in a sub-process doesn't work because environment variable settings are inherited by child processes, but not propagated up to parents. So they only affect the child process and its descendants.

Visual Studio projects are executed by MSBUILD, or the same processor running under the IDE. There's nothing in stock MSBUILD that sets environment variables, as far as I know.

Here's an old StackOverflow post that shows how to add a task that sets an environment variable:

social.msdn.microsoft.com/.../how-to-set-envrionment-variables-in-msbuild-file

There's also a NuGet package for it:

www.nuget.org/.../MSBuild.SetEnvVariable

That could be adapted to read a file (the one you build dynamically) and apply the settings it finds in it. It's not a trivial change, but it's doable.

Another alternative would be to create a script that 1) processes your settings and 2) invokes the COBOL compiler. Then use that from Makefile projects. But that gives up the advantages of using COBOL projects.

Or build from outside the IDE using a script like this:

   call set-my-variables.cmd

   msbuild myproject.cblproj (or mysolution.sln)

If you want to build from the IDE, you could create a makefile project that runs that script. There are various options for msbuild that you can use to set the build configuration (debug/release), etc.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>