- changed status to open
$(ProjectDir) doesn't resolve properly
I've just upodated to latest version of solutionBuildEvents (0.11.2.50249) to check if an issue I found is resolved but ...
Thing is like this - I have four projects under my solution and I've made a small program to fix version numbers. Thus I created a pre-build event with settings: Control: Enabled, Waiting for completion, MSBuild Support, SBE-Scripts support Processing mode: Files mode Files to execute: versionfix $(ProjectDir)VersionNo.h
versionfix is a small program that changes the .h file to set my desired version number. Now the issue is this - No matter which project I build, SBE always prepares and executes command for the project, which is set as 'Start-up project', and not for the one currently being built.
Should be easy to reproduce - create a solution with two projects, add a pre-build event in file mode, using the $(ProjectDir) in the path/parameters, then try to build the non-startup project and check the SBE output.
Comments (13)
-
repo owner -
repo owner - changed component to MSBuild
-
assigned issue to
- changed version to 🍂 v0.11.x
-
repo owner ok, I see ... what you mean :) well, it's default behavior - not a bug
This is so, because this can be used for all projects at once as Solution-wide
For your specific project you should use the syntax as
$(ProjectDir:<ProjectName>)
- use UI-helper fromSettings
-Tools
-MSBuild Properties
You can also use conditional statements for this etc.
please use this full example for more details:
- Automatic Version Numbering
- Our actual Wiki
You can also test/debug your scripts in
Settings
-Tools
-SBE-Scripts testing tool
Report me again if you still have any problems or questions.
Thanks for using,
-
I still have an issue ... as stated above, I'm using SBE in files mode and I've tried to the above mentioned fix as
versionfix $(ProjectDir:<ProjectName>)VersionNo.h
and
versionfix $(ProjectDir:<$(ProjectName)>)VersionNo.h
... first one said it doesn't know the 'ProjectName' project, the other didn't resolve anything and basically just called 'versionfix VersionNo.h' without any path.
... what did work, was to place a versionfix $(ProjectDir:MyProjectName) in four times (for each project) - but then all four get changed even if I build just one. Then I tried:
#[$(Project)===MyFirstProject) {versionfix $(ProjectDir:MyFirstProject)VersionNo.h}]
... to make conditional runs and got the reply of
Fail: SBEScripts-selector: not found component for handling - '[$(Project)===MyFirstProject) {"versionfix", $(ProjectDir:MyFirstProject)VersionNo.h}]'
... and next try:
#[($(Project)===MyFirstProject) { #[File call("versionfix",$(ProjectDir:MyFirstProject)VersionNo.h)]}]
... which resulted in nothing being called at all.
So - right now I'm a bit stuck at proper syntax to get things properly done ... My personal favorite would be actually:
versionfix $(ProjectDir:<$(ProjectName)>)VersionNo.h
... but looks like nested resolves don't work as I'd expect.
Any ideas?
PS: I've also found one new bug (didn't happen earlier and might be actually something with my configuration) - If I go to SBE settings, then click on 'MSBuild Properties', and then try to sort the properties by name (clicking on the header) - everything freezes for a while, then VS automatically restarts (VS 2013 Update 4 Community edition)
-
Just another update ... reading what I wrote above I saw that my favorite should actually be 'versionfix $(ProjectDir:$(ProjectName))', which I just tried and got the same result as before (nothing being resolved).
-
repo owner :)
'<ProjectName>' - your project name without '<>' it means above
and
[$(Project)===MyFirstProject)
also not a correct syntax ... andFail: SBEScripts-selector: not found component for handling
is ok.My personal favorite would be actually:
versionfix $(ProjectDir:<$(ProjectName)>)VersionNo.h
yes, you can this as a:
versionfix $(ProjectDir:YourProjectName)VersionNo.h
for example:
versionfix $(ProjectDir:bzip2)VersionNo.h
where 'bzip2' it's a project name for current sample in your solution
you can also use any other variables if you don't put a fixed project name, for example:
$($(ProjectDir:$(SolutionName)))
i.e. many variables can be evaluated with nested levels
Or use 'Scripts' mode instead of 'Files mode' for example:
#[var verno = $(ProjectDir:MyFirstProject)VersionNo.h] #[($(Project) == "bzip2") { #[File call("versionfix", "#[var verno]")] }]
Or any conditional statements in 'Files mode' but do not forget about spaces.
ah yes, you can also enable 'Debug mode' in program and see what's going on with additional details in
Output
->Soultion Build-Events
-
repo owner PS: I've also found one new bug (didn't happen earlier and might be actually something with my configuration) - If I go to SBE settings, then click on 'MSBuild Properties', and then try to sort the properties by name (clicking on the header) - everything freezes for a while, then VS automatically restarts (VS 2013 Update 4 Community edition)
yes, thanks! also reproduced
-
Thanks a LOT! $($(ProjectDir:$(ProjectName))) actually works! Think it's a curious syntax though with additional $() - my guess would be $(ProjectDir:$(ProjectName)) ... which I tried and didn't work. But - I got my solution and am rather happy with it :) Thanks a lot for your extension and support.
-
repo owner good news :)
please don't forget about Wiki
- new examples, features and other info a partially appears, so look it periodically (you can also add your real examples for others or improve current pages)...
Latest public releases see in Visual Studio Gallery page.. trivial bug in 'MSBuild Properties' window I'll fix later as will the time
-
repo owner - changed status to wontfix
-
repo owner bug with 'MSBuild Properties' window fixed in 82dbc31 and should be included in next official patch
optional, you can check this in debug version
-
repo owner - removed version
-
repo owner In v0.11.4+ should be incompatible changes with recursive evaluation of MSBuild Properties
For example:
v0.11.4+ older versions: $(ProjectDir:$(SolutionName))
$($(ProjectDir:$(SolutionName)))
$(ProjectDir:$(ProjectName))
$($(ProjectDir:$(ProjectName)))
This changed with fa01add
You can check this with debug version before new public release
- Log in to comment
Thanks for report,
I check it coming soon.
For this moment we have no any similar notices about of the same problems.
btw, your variant as similar here - Variant with the own utility as part of solution (or variant for version < v0.9) ?
And this also for older versions (v0.9.x & v0.10.x) ? if I understood correctly
Please stay in touch! for a quick resolving problems