11

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.

4
  • Can you clarify what you mean by "output directory of an ASP.NET RC2 project"? Do you mean, "output directory of the compiler?" Commented Jun 6, 2016 at 16:02
  • 1
    The output directory of the compiled project. It looks like the default is "bin\Debug\net46\win7-x64" Commented Jun 6, 2016 at 17:11
  • Just out of interest; why would you want to do this? And is this about the build, or the publish step? Commented Jan 24, 2023 at 9:56
  • One reason to do it is so that all build output is covered by single "ignore" directive in Git or Mercurial. Commented Apr 28, 2023 at 15:03

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Is there anyway to do this from within Visual Studio?
I'm not sure. You would need to go exploring in how MSBuild wraps dotnet.exe. These definitions are in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet
3

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.

1 Comment

This generates quite a few folders in the directory I specify: <projectname>\bin\Debug\net461
3

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.