0
votes

For my work I have to define a pre build event in a powershell script, which will be added to the target project that I install the NuGet package in. The script installs fine the first time, the pre build event is being added the right way like this:

xcopy $(SolutionDir)Some\Path $(ProjectDir)Some\Other\Path

When I uninstall and install my NuGet package again, the existing pre build events are being requested from the target project. The problem is that when an environment variable like $(ProjectDir) or $(SolutionDir) is being used in the pre build event, my powershell script gets the value that is associated with the variable. Like so:

c:\Path\To\Solution\Dir

or:

C:\Path\To\Project\Dir

But I want it to give me the string with the env variables in it. How can I get the literal value from the pre build events in powershell?

Tim

UPDATE::

I have done a little more research and concluded that the environment variables in the build events won't be replaced UNLESS it is a Windows Installer project.

1

1 Answers

0
votes

How to get literal string value of Project Pre Build Event property

AFAIK, you can't get literal string value of Project Pre Build Event property. Because Macros are expanded by the Preprocessor, which happens even before the code is compiled. It is a purely textual replacement.