- 1 year ago
Build for Linux when launchSettings profile is WSL2
Comment
1 / 1
To build for Linux when the launchSettings
profile is WSL2, you can follow these steps:
- Open the
.csproj
file of your .NET Core project in a text editor. - Add the following lines at the end of the file, just before the closing
</Project>
tag:
php<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<RunCommand>dotnet</RunCommand>
<RunArguments>build</RunArguments>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<RunCommand>dotnet</RunCommand>
<RunArguments>build</RunArguments>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>
- Save the
.csproj
file and close the text editor. - Open a command prompt or terminal and navigate to the directory of your project.
- Run the following command to build the project:
dotnet build
This will build the project for Linux, even when the launchSettings
profile is set to WSL2.