Closed NPatch closed 8 years ago
I also tried moving the post build xcopy into
<Target Name="AfterBuild">
<Exec Command="xcopy '$(TargetPath)' '$(RootProductDir)Installer\' /YSED" />
</Target>
but it was the same.
I guess it'd be pretty good if the Project Properties UI could expose a tab where we could define msbuild properties instead. They work with build events and anything else. As it is, I could define them manually through code but it would be much better if they were accessible or visible from the Properties UI as other people might need to use it eventually.
Where do you define the MSBuild $(RootProductDir)
property? Check your verbose MSBuild output to see where the property is set and what value it has when PreBuildEvent
and PreBuildEvent
are evaluate by MSBuild.
Actually they are not MSBuild properties so much as constant variables inside a wix MSBuild property.
Also, somehow it worked. No idea why. I didn't exactly change something. I think there might be a problem with whatever processes the changing of wix project properties in VS through UI.
For example, at some point even though I had problems only with the PostBuildEvent and PreBuildEvent was working fine and evaluating $(RootProductDir), even that stopped working. Basically it started evaluating it to "", so it failed on build every time.
Now they both work...and I use the same way to evaluate RootProductDir in both events as the one given above.
And now they don't work again and I haven't changed a thing....I think this is probably a VS Integration thing. I did check evaluation at some point. I used a SET TEMP=$(RootProductDir)Installer\ and I did see it evaluated properly in the Build Output of VS. Now it doesn't evaluate correctly.
If you did SET RootProductDir=<some value>
on command line MSBuild used it as it's $(RootProductDir)
property value.
MSBuild properties are unrelated to the constants defined for WiX tools using the <DefineConstants>
property.
Right, I meant I didn't use MSBuild Properties. I defined a preprocessor constant since that's what I could use through the UI. But sometimes it doesn't evaluate correctly in pre/post build events. It evaluates to empty string.
The SET was just so I could try and expand the preprocessor constant, since batch code in the pre/post build events gets evaluated and printed in the Build Output.
You must have confused my statement "I guess it'd be pretty good if the Project Properties UI could expose a tab where we could define msbuild properties instead" . I'm new to WiX and it's a bit difficult to figure out how I'm supposed to evaluate each type of variable/constant depending on where it was defined and where its being called for evaluation. So I thought it'd be good if you could have MSBuild properties instead which can be seen through anything , be it MSBuild , or WiX and have a more constant way of calling the property.
There's nothing in wix.targets to convert preprocessor variables to MSBuild properties. It's more typical to want to go the other way. It's unusual to have a project system let you set raw MSBuild properties; that's something done via the command line or via an imported project.
@barnson I only mentioned MSBuild properties since I think they have the scope closest to a global out of everything. The point was to be able to set a property of some kind (say ApplicationName) once that I could both access from a Pre/Post build event safely and from wix code as well. My problem was that I tried to use preprocessor variables(the way all tutorials on wix say) since I initially thought they had that scope and successfully used it in a Pre-Build event but it gave me grief in the Post-Build event. The part about MSBuild properties was just a suggestion. If you can tell me where I went wrong and whether there's an elegant solution to it, I'm happy to hear about it.
MSBuild properties are going to be useful in other targets.
Can you tell me why the PostBuild event couldn't read the preprocessor variable? Does it go out of scope as soon as the build ends?
For support please contact the wix-users mailing list.
Bugs
If this issue is a bug:
sample code:
But the post build event doesn't expand the RootProductDir variable even though its practically the same as the pre build event and the xcopy in the pre build event works.
As you can see the destination folder is "Installer\". Also whitespace in the variable are not an issue since both directories are wrapped with "".