How to change the default location of WebProjectOutputDir?

Does anyone know, based on each project, whether it is possible to set WebProjectOutputDir in Visual Studio. I want to have it so that when I press Ctrl + Shift + B it automatically creates my web project in a specific directory, but I also need to override this in my build script.

+7
web-applications visual-studio msbuild
source share
2 answers

It’s inconvenient to do this correctly based on how Microsoft.WebApplications.targets defines the _CopyWebApplication target and how Microsoft.Common.targets handles the OutDir and OutputPath .

If you want to change this in the project file, you need to:

  • Declare the WebProjectOutputDir property after importing into Microsoft.WebApplications.targets
  • Declare the OutDir property before importing into Microsoft.WebApplications.targets

There are several reasons why you should do this.

Microsoft.WebApplications.targets override any WebProjectOutputDir declaration if it is declared before the import statement. Therefore, he must come after.

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

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

Looking at the condition, you will see that the goal will not be fulfilled if OutDir and OutputPath are the same value. You cannot just change the OutputPath, because the OutDir based on the OutputPath , so you need to change the OutDir and make sure it is before importing into this file, because other properties are built on the basis of this property.

Less than ideal, but hopefully this helps you.

+16
source share

I came across this when using Visual Studio for Mac while compiling a Umbraco project. The following error will occur in the building:

Error MSB4044: The KillProcess task was not assigned a value for the required ImagePath parameter

It returned a null value for WebProjectOutputDir when compiling Rosyln, etc. Only the web project in the solution collected these elements, so I manually edited the csproj file of the web project and added the following to the global file at the top:

  ... <WebProjectOutputDir>.\</WebProjectOutputDir> </PropertyGroup> 

The problem is resolved.

0
source share

All Articles