Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change WebProjectOutputDir default location?

Does anybody know, on a per project basis, whether you can set the WebProjectOutputDir in Visual Studio. I want to be able to have it so that when i hit Ctrl + Shift + B it automatically builds my web project to a specific directory, but I also need to be able to override this in my build script.

like image 681
Matt Brailsford Avatar asked Feb 26 '10 16:02

Matt Brailsford


1 Answers

It is unnecessarily awkward to correctly do this based on the way that Microsoft.WebApplications.targets defines the _CopyWebApplication target and how Microsoft.Common.targets treats the OutDir and OutputPath properties.

If you want to change that in the project file itself then you should:

  • Declare the property WebProjectOutputDir after the import to Microsoft.WebApplications.targets
  • Declare the property OutDir before the import to Microsoft.WebApplications.targets

There are a few reasons why you have to do this.

Microsoft.WebApplications.targets will override any declaration of WebProjectOutputDir if it is declared before the import statement. Therefore it has to come after.

Also inside of Microsoft.WebApplications.targets the _CopyWebApplication is defined as follows:

<Target Name="_CopyWebApplication" Condition="'$(OutDir)' != '$(OutputPath)'" >
  ....
</Target>

Taking a look at the condition you will see that the target will not be executed if OutDir and OutputPath are equal to the same value. You cannot just change OutputPath because OutDir is based on OutputPath, so you have to change OutDir and make sure that it is before the import to that file because other properties are built based on that property.

Less than ideal, but hopefully that helps you.

like image 105
Sayed Ibrahim Hashimi Avatar answered Dec 02 '22 06:12

Sayed Ibrahim Hashimi