$(ProjectDir) doesn't resolve properly

Issue #29 wontfix
Former user created an issue

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)

  1. Denis Kuzmin 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 from Settings - Tools - MSBuild Properties

    You can also use conditional statements for this etc.

    please use this full example for more details:

    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,

  2. Buldozer

    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)

  3. Buldozer

    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).

  4. Denis Kuzmin repo owner

    :)

    '<ProjectName>' - your project name without '<>' it means above

    and [$(Project)===MyFirstProject) also not a correct syntax ... and Fail: 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

  5. Denis Kuzmin 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

  6. Buldozer

    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.

  7. Denis Kuzmin 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)...
      • e.g. syntax for nested properties $($(ProjectDir:$(SolutionName))) already contained in examples here (for complex sample with syntax etc. you can see this - our current script for assembling the vsSolutionBuildEvent v0.11 with CI tools)

    Latest public releases see in Visual Studio Gallery page.. trivial bug in 'MSBuild Properties' window I'll fix later as will the time

  8. Log in to comment