5

I'm trying to port a project from Windows to Mac. On Windows, he Windows project uses environment variables that are set in the Windows system itself. On Mac it seems I have to set the environment variables from within Visual Studio on a project-by-project basis. The six variables are the same for each project, and there are more than 30 project files, so I figure there has to be an easier way. Is there a config file or some easier way to set these up? Most of the variables are to access configurations for NuGet or Azure.

Raydot
  • 1,458
  • 1
  • 23
  • 38
  • 1
    Are they different for each project or the same? Also not sure how they are set for each project on Windows - can you explain? On the Mac you can set environment variables globally for VS Mac by running `launchctl setenv VARNAME VARVALUE` from the Terminal.app, and then restart Visual Studio for Mac. Not sure if that helps or not. – Matt Ward Mar 19 '20 at 18:17
  • @MattWard they're the same for each project. On Windows they are set in the windows environment variables. I'm going to try launchctl. – Raydot Mar 19 '20 at 22:17
  • @MattWard can I manage this with a plist? – Raydot Mar 19 '20 at 22:22
  • A .plist file is not used to set values when building with msbuild. – Matt Ward Mar 20 '20 at 13:05

1 Answers1

1

I'm not sure if this will address your needs, but we define some environment variables in a bash file which launches VS, which in turn inherits the variables:

export FOO=/Some/Directory/
export BAR=/Another/Directory
/Applications/Visual\ Studio.app/Contents/MacOS/VisualStudio

The variables can be referenced in the .vcxproj or .csproj project file as $(FOO).

Pierre
  • 4,114
  • 2
  • 34
  • 39
  • I got to the bottom of this and it turned out there was just a completely different way of doing it on the Mac. I figured it out...eventually. – Raydot Oct 27 '20 at 18:35
  • 3
    @DaveKanter Care to share your findings? We're no wiser without. – Pebermynte Lars Dec 16 '20 at 15:55
  • @PebermynteLars at the time I was working on the solution was that *some* of the variables could be set in Mac VS preferences directly. But as to how to set the others, I never figured it out. Ended up switching to a PC for the remainder of the task. – Raydot Dec 16 '20 at 21:08