views:

275

answers:

1

Hi Guys,

Does anybody know, on a per project bases, 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 automaticaly builds my web project to a specific directory, but I also need to be able to override this in my build script.

Many thanks

Matt

+2  A: 

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.

Sayed Ibrahim Hashimi
+1 hopefully this is enough info for me to figure out a similar problem involving a build script instead of at the project file level.
Maslow