Bug 15963 - $(SolutionDir) must resolve to an absolute path in PostBuildEvent
Summary: $(SolutionDir) must resolve to an absolute path in PostBuildEvent
Status: RESOLVED DUPLICATE of bug 15964
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-11-06 09:27 UTC by rryk.ua
Modified: 2013-11-16 14:08 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 15964

Description rryk.ua 2013-11-06 09:27:14 UTC
In post build events (created in Visual Studio), $(SolutionDir) is resolved as a relative path to the project dir, while the documentation on http://msdn.microsoft.com/en-us/library/42x5kfw4(v=vs.90).aspx says it must be absolute:

$(SolutionDir) - The directory of the solution (defined with drive and path); includes the trailing backslash '\'.

Essentially this creates a problem when writing a command similar to this:

  <PropertyGroup>
    <PostBuildEvent>xcopy /y /s "$(SolutionDir)ThirdParty\V8.NET\Net40\Release" "$(SolutionDir)FIVES\bin\$(ConfigurationName)\"</PostBuildEvent>
  </PropertyGroup>

It resolves to

xcopy /y /s "..\..\ThirdParty\V8.NET\Net40\Release" "..\..\FIVES\bin\Debug\"

and fails because current directory is

D:\Projects\CopyFives\Plugins\Scripting\bin\Debug

while solution is located in

D:\Projects\CopyFives.
Comment 1 Mikayla Hutchinson [MSFT] 2013-11-06 12:04:52 UTC
Do you have this problem when building in xbuild, or only when building in Xamarin Studio?
Comment 2 Mikayla Hutchinson [MSFT] 2013-11-06 12:22:17 UTC
Also, are you certain about that current directory? It should be the project directory, not the output directory. I suspect it's actually a duplicate of bug 15964.
Comment 3 Mikayla Hutchinson [MSFT] 2013-11-15 16:48:36 UTC
.
Comment 4 Mikayla Hutchinson [MSFT] 2013-11-15 16:48:55 UTC

*** This bug has been marked as a duplicate of bug 15964 ***
Comment 5 rryk.ua 2013-11-16 08:33:40 UTC
That is not the duplicate. In the other bug $(Solution...) variables were completely undefined, but in my case they are defined, although incorrectly.

Given this pre-build event:

    <PreBuildEvent>
        echo $(SolutionDir)
        echo $(ProjectPath)
    </PreBuildEvent>

it prints

    ..\..\
    D:\Projects\FIVES\Plugins\ClientManager\ClientManager.csproj

but should print

    D:\Projects\FIVES\
    D:\Projects\FIVES\Plugins\ClientManager\ClientManager.csproj

according to MSDN documentation.

I am using Xamarin Studio 4.2.1 (build 1) on Windows.
Comment 6 rryk.ua 2013-11-16 08:36:52 UTC
Additional info:

The project that is being build is located in 

    D:\Projects\FIVES\Plugins\ClientManager\

and while it may seem that 

    ..\..

refers to the same folder as

    D:\Projects\FIVES\

it is not the case, because current directory is set to

    D:\Projects\FIVES\Plugins\ClientManager\bin\Debug\

and

    ..\..

refers to

    D:\Projects\FIVES\Plugins\ClientManager\
Comment 7 Mikayla Hutchinson [MSFT] 2013-11-16 14:08:52 UTC
I tested the value of $(SolutionDir) after fixing bug 15964 and confirmed it was absolute. Note that the fix did not make it into 4.2.1.

*** This bug has been marked as a duplicate of bug 15964 ***