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.
-
Can you clarify what you mean by "output directory of an ASP.NET RC2 project"? Do you mean, "output directory of the compiler?"natemcmaster– natemcmaster2016-06-06 16:02:21 +00:00Commented Jun 6, 2016 at 16:02
-
1The output directory of the compiled project. It looks like the default is "bin\Debug\net46\win7-x64"Zeus82– Zeus822016-06-06 17:11:24 +00:00Commented 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?Zimano– Zimano2023-01-24 09:56:19 +00:00Commented 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.AbuNassar– AbuNassar2023-04-28 15:03:23 +00:00Commented Apr 28, 2023 at 15:03
3 Answers
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.
2 Comments
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.
See if this helps.
1 Comment
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>
