3

I got a very simple problem with the Visual Studio 2010 Professional C++ debugger when setting environment variables.

Described in
http://msdn.microsoft.com/en-en/library/kcw4dzyf.aspx
Paragraph "Environment (Local Windows Debugger)".

I created a standard Win32 console project. I am setting the environment in project properties → Debugger:

TEST=asdf
OTHER=qwer

And printing the environment variables in the _tmain(...):

cout << "Hello " << getenv("TEST") << endl;

I would expect an out like:

"Hello asdf"

But instead I always get:

"Hello asdf OTHER=qwer"

How to fix this?!


It seems to be a DEU version bug.

I just filed a bug report: https://connect.microsoft.com/VisualStudio/feedback/details/727324/msvs10-c-deu-debugger-environment-variables-missing-linefeed#details

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Donny
  • 33
  • 5
  • This doesn't repro for me - are you using VS 2010 with or without SP1? (I'm using SP1) – Michael Burr Feb 29 '12 at 21:37
  • Got all updates. So this is SP1. Version 10.0.40219.1 SP1Rel. I tested this on Professional and Ultimate on 2 different PCs so far. But always DEU edition. – Donny Feb 29 '12 at 21:44
  • This data gets stored in the `*.vcxproj.user` file - take a look in there and see what's delimiting the strings - mine has 0x0a chars between the strings. – Michael Burr Feb 29 '12 at 21:46
  • 1
    yeah, line feed makes sense. there it is: BLA="asdf" BLO="asdfwqe" no delimiter. but if i paste BLA="asdf"0x0aBLO="asdfwqe" it doesnt make a change. so this is a bug in deu version? – Donny Feb 29 '12 at 21:51
  • 1
    Just to be clear - there's a single byte in the ``vcxproj.user` file that has the numeric value 0x0a (ie, it's a linefeed character), right? I'd be very surprised if this is a bug because of using the DEU edition, but I suppose it's possible. – Michael Burr Feb 29 '12 at 22:14
  • well, a buddy tested this at work (EN_Version) which works. he just tested this at home (DEU_Version) which fails. crappy bug 8[ – Donny Feb 29 '12 at 22:18
  • please post that on Microsoft's connect.microsoft.com site so there's some hope it'll be fixed in VS 11. – Michael Burr Feb 29 '12 at 22:24
  • same on visual studio 2019 community – imbr Nov 28 '19 at 01:15

3 Answers3

1

Running into a similar problem feeding this property programmatically, I bumped into this github file. The separator is "&#xA;" in xml format, a.k.a. line feed. Using Environment.Newline solved the issue in dot net.

In interactive mode within the GUI, you want to click the edit button and use the rerun key to split your variables.

Florent DUGUET
  • 2,786
  • 16
  • 28
0

Best solution so far:

Considering your example:

TEST=asdf
OTHER=qwer

Edit the .vcxproj adding inside <Project>:

  <Project .... >
  ...

  <PropertyGroup Label="UserMacros">
  <TEST>asdf</TEST>
  <OTHER>qwer</OTHER>
  </PropertyGroup>

  ...
  </Project>

You can also add this on a *.vcxproj.user or a *.props file as you prefer.

imbr
  • 6,226
  • 4
  • 53
  • 65
0

Do you need to separate the environment variables with semicolons or some other kind of delimiter? It seems like TEST is getting assigned to asdf OTHER=qwer, not just asdf.

Matt Kline
  • 10,149
  • 7
  • 50
  • 87
  • 1
    yes, "TEST" is obviously assigned to "asdf OTHER=qwer". i tested all delimiters i could image, but none of them fixed it. – Donny Feb 29 '12 at 21:17