Sysprogs forums › Forums › VisualGDB › "Before Building" custom step – "PATH" missing?
- This topic has 6 replies, 2 voices, and was last updated 5 years, 1 month ago by support.
-
AuthorPosts
-
October 8, 2019 at 16:00 #26101SeidleroniParticipant
I have a project that uses a batch file to call a python script. For reasons that I don’t understand, the batch file that I have VisualGDB executing does not have access to the system environments Path variable. When I enter ECHO %PATH%, it returns an empty string. This is strange because when I do a “set” command, all of the other system environment variables show up. What causes this and what workaround can I use to get access to the path directories?
October 8, 2019 at 18:22 #26105supportKeymasterSorry, we are not aware of this issue. Please try checking if other variables get overridden as well (e.g. by running ‘set’ instead).
If this doesn’t help, please try creating the most basic repro project and share it with us so that we could try replicating this. That said, please also ensure the VS instance you are using doesn’t inherit some custom environment and that your environment block doesn’t exceed Windows limits.
October 8, 2019 at 20:58 #26110SeidleroniParticipantNone of the other variables get overridden, just ‘path’ which is now empty. I noticed that if I open the project via Visual Studio (Start–>Visual Studio 2017, and then doing File->Open->Solution), I now have access to ‘path’. If I have *never* opened it that way, but only just opened it by double-clicking the solution, then the path is missing.
Way to reproduce (for me):
- Take a working project
- Copy and paste the project (so it creates a new folder. can be in the same directory.)
- Double-click the solution
- Create a pre-build batch file that just has “set” or “python -h” in it.
- Build the project
- The project will not show path as a system env variable. It will also complain about not being able to find python (due to missing path).
- Open Visual Studio Start->Visual Studio 2017
- Open solution
- Build project again. Now you will see that it does have the path variable and “python -h” shows the appropriate python help info.
Can you reproduce it with this? You can try one of your own projects, but be sure to do a copy/paste.
- This reply was modified 5 years, 1 month ago by Seidleroni.
October 8, 2019 at 21:09 #26113supportKeymasterSorry, this might be something set on the VS level. Please try running notepad.exe instead of the batch file (so that the build waits until you close Notepad).
Then use the Process Explorer to check the environment block of the Visual Studio itself (devenv.exe), launched Notepad instance and the MSBuild executables (msbuild.exe) if you are using MSBuild.
Let us know at which stage is the PATH reset and we might be able to suggest a workaround.
October 10, 2019 at 12:55 #26132SeidleroniParticipantSo by doing this, here is the hierarchy and breakdown:
- devenv.exe (Path is present)
- MSBuild.exe (Path is *not present*)
- vgagent.exe (Path is *not present*)
- cmd.exe (Path is *not present*)
- notepad.exe (Path is *not present*)
- cmd.exe (Path is *not present*)
- vgagent.exe (Path is *not present*)
- MSBuild.exe (Path is *not present*)
What are the next steps to work around this?
October 10, 2019 at 18:51 #26137SeidleroniParticipantAfter spending an inordinate amount of time on this, I fixed the issue by deleting my PreBuild action and then recreating it. Attached is an image comparing the vgdbsettings file change that made it happen. What could cause this? Is this just a stupid error on my part?
Attachments:
You must be logged in to view attached files.October 10, 2019 at 19:19 #26139supportKeymasterSorry, the settings in both cases look equivalent. To be fully sure, please consider reverting them back and forth 2-3 times and checking if the problem reoccurs consistently.
As a long-term workaround, please consider setting the GNUToolchainExtraPath MSBuild variable in the .vxcproj file. It is used internally by VisualGDB to propagate path directories exported by the selected toolchain, so you can edit it to inject the Python path into the environment as well.
Also, as the variable is lost between Visual Studio and MSBuild, it could be worthwhile verifying if the problem can be reproduced with the regular Exec task on a regular non-VisualGDB project and checking with the Visual Studio support whether it’s a bug that could be fixed on the VS side or if there is a setting controlling this behavior.
-
AuthorPosts
- You must be logged in to reply to this topic.