Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core Change Build directory

Does anyone know how to change the Build directory of an ASP.NET Core project? In the project settings under build, the output path is readonly.

like image 746
Zeus82 Avatar asked Jun 06 '16 15:06

Zeus82


People also ask

How do I change the build directory output?

Right-click on the project node in Solution Explorer and select Properties. Expand the Build section, and select the Output subsection. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.

How do I change the project path in Visual Studio?

In Visual Studio, click Tools > Options. Expand Projects and Solutions and click Locations. The Projects location field defines the default location for storing new projects. You can change this path if you are using a different working folder.

How do I change directories in Visual Studio?

If you've already installed it and want to change the location, you must uninstall Visual Studio and then reinstall it. In the Shared components, tools, and SDKs section, select the folder where you want to store the files that are shared by side-by-side Visual Studio installations.


3 Answers

You can define pre/post script commands in your project.json in the scripts section. Even execute multiple commands, when you turn the postcompile from string to an array ["command1", "command2", "command3"]

Other workaround is-

Open your ASP.NET core project .xproj file in Notepad and change OutputPath

from

<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>

to

<OutputPath Condition="'$(OutputPath)'=='' ">E:\SanketTest</OutputPath>

Once done, reload your project and it will automatically build in specified location.

build output path

See if this helps.

like image 147
Sanket Avatar answered Oct 31 '22 00:10

Sanket


Edit the .csproj file manually. Set the Outputpath as desired:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
  <OutputPath Condition="'$(OutputPath)'=='' ">..\bin\Release\</OutputPath>
</PropertyGroup>

This will still generate subfolders for the framework version and the runtime identifier. To remove those add this to your project file:

<PropertyGroup>
  <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
  <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
like image 36
Tigerware Avatar answered Oct 30 '22 22:10

Tigerware


ASP.NET Core projects are built using the .NET Core CLI. The output can be controlled by adding options the command-line call do "dotnet build".

Example:

dotnet build --output bin/whatever/ --framework netcoreapp1.0

See dotnet build --help for all available parameters.

like image 37
natemcmaster Avatar answered Oct 31 '22 00:10

natemcmaster