Search

$(ProjectDir) Build Event Macro is Blank in Database Projects by Shane Hancock

Closed
as Won't Fix Help for as Won't Fix

11
0
Sign in
to vote
Type: Bug
ID: 560596
Opened: 5/21/2010 12:03:32 AM
Access Restriction: Public
3
Workaround(s)
10
User(s) can reproduce this bug
When I use the $(ProjectDir) macro in my post build event for my SQL 2008 Database Project, it expands to an empty string when I compile my project.
Details (expand)

Product Language

English

Visual Studio Version

Visual Studio 2010

Operating System

Windows 7

Operating System Language

English

Steps to Reproduce

-Create a new SQL Server 2008 Database Project in VS2010.
-Go into properties of Database Project.
-Go into Build Events tab of properties page.
-Type '$(ProjectDir)\test.bat' into the post build event command line box.
-Create an empty file called 'test.bat' in the same folder as your .dbproj.
-Save and try to build the project.

Actual Results

Compilation will fail with a message of:

\test.bat
'\test.bat' is not recognized as an internal or external command

Expected Results

The $(ProjectDir) macro variable should expand to the full path of the .dbproj file, causing test.bat to be executed in the post build and compilation should succeed
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey.

 

File Attachments
File Name Submitted By Submitted On File Size  
Database1.zip (restricted) 5/24/2010 -
Sign in to post a comment.
Posted by StefDBA on 11/2/2011 at 9:07 AM
http://connect.microsoft.com/VisualStudio/feedback/details/668658/some-macros-do-not-expand-in-post-build-event-even-with-sp1
Posted by StefDBA on 5/16/2011 at 1:56 AM
Bug still active in vStudio 2010 SP1
Posted by StefDBA on 9/2/2010 at 9:36 AM
Hi,

I have the same issue on other Macros as well in SQL 2008 DB project under VStudio 2010.

So far, on $(ProjectName) and $(FinalDeployScriptFile).

Thanks,
Stef
Posted by Microsoft on 7/7/2010 at 10:38 AM
Hi Shane,

Thank you for submitting this issue. We have reproduced this issue and have added it to our product backlog. It will be considered for a future release of Visual Studio.


Thanks,

Barclay Hill
Sr. Program Manager | Visual Studio Product Team (Data Tools) | Microsoft Corporation
Posted by Microsoft on 5/26/2010 at 4:35 AM
Thanks for your feedback. We were able to reproduce the issue you are seeing. We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Shane Hancock on 5/24/2010 at 12:24 AM
Ignore that last post. I meant to say:


Actually, it looks like you have reproduced the problem. The fact your result returned:

The command "\test.bat" exited with.....

means the $(ProjectDir) macro didn't expand to the correct path since it there is no path prior to the \ character. If the $(ProjectDir) expanded to the correct path, the compiler should locate test.bat, execute it and compilation should succeed without any errors.
Posted by Shane Hancock on 5/24/2010 at 12:19 AM
Actually, it looks like you have reproduced the problem. The fact your result returned:

The command "\test.bat" exited with.....

means the $(ProjectDir) macro didn't expand to the correct path since it there is no path prior to the \ character. It should have said:

The command "C:\X\Y\Z\test.bat" exited with....

Where X,Y,Z is the path to the .dbproj file that you're compiling.
Posted by Microsoft on 5/23/2010 at 11:53 PM
Thank you for reporting this issue. In order to research the issue reported, we must first reproduce in our labs. Unfortunately, we are unable to reproduce the issue with the steps you provided. We tried to repro with the following steps:

1.Create a sql server 2008 database project.
2.right click the project in the solution explorer ,click properties.
3.At build Event tab,tpye '$(ProjectDir)\test.bat' in post build command line.
4.Create an empty file named 'test.bat' in the project folder.
5.Save and build the project.

result:
Error MSB3073: The command "\test.bat" exited with code 9009.

Could you please provide us with the following information?

Upload your zipped project file to us.

It would be greatly appreciated if you could provide us this information as quickly as possible.

Thank you,
Visual Studio Product Team
Posted by Microsoft on 5/21/2010 at 4:02 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by ajhuddymsdn on 12/2/2011 at 11:42 AM
$(MSBuildProjectDirectory) is a good workaround. Nice of Microsoft to lets us know.
Posted by Serghei Gorodetki on 6/17/2010 at 9:25 AM
Thanks chaneh20. $(MSBuildProjectDirectory) works as well . But there isn't this variable in Macros list of "Post -Build event Command line" Window.
Posted by Shane Hancock on 5/21/2010 at 12:08 AM
The $(MSBuildProjectDirectory) macro variable seems to expand the project directory i.e. it does what $(ProjectDir) is meant to do