简体   繁体   中英

Visual Studio 2022. Can I build project with `dotnet build` by default instead of MSBuild?

I want to develop, build and deploy app to my Raspberry Pi 3 from Visual Studio 2022 on my working PC with Windows 10.

Found, that I can build native Linux app with dotnet.exe build -r linux-arm64.\TestLinuxDeploy\TestLinuxDeploy.csproj --self-contained

So, can I somehow modify single project behavior, to make default build ( Ctrl+Shift+B ) to run above command instead of building with MSBuild? Or redefine default MSBuild Build target, or something else...

My stack of googled info literally overflowed with tons of information about VS build process, but no clear one.

I expect, that I can define some properties in .csproj file, like runtime , self-contained , single-package , then hit big red "BUILD" button, and project will be built with dotnet build <my parameters>

MSBuild can be hosted within another application and this is what the dotnet tool is doing. It is the same build engine regardless of whether you use msbuild or dotnet msbuild (or dotnet build (which is essentially dotnet msbuild /t:build ) or one of the other dotnet sub-commands that use the build engine).

There are two major implementations of .NET:

  • ".Net Framework", the original implementation of .NET, is Windows only.
  • ".Net" (previously known as.Net Core), is cross platform. (The naming is not at all confusing.)

The .NET SDK includes the dotnet tool and supports the ".Net" implementation but doesn't support the ".Net Framework" implementation. Visual Studio for Windows supports both implementations.

You can't change Visual Studio to use dotnet msbuild instead of msbuild but you don't need to.

You are correct to expect that there are properties.

Visual Studio uses separate publishing profile files (with a.pubxml extension).

The equivalent property for -r is RuntimeIdentifier , eg:

<PropertyGroup>
  <RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
</PropertyGroup>

See " RuntimeIdentifier ".

--self-contained maps to a SelfContained property.

Both properties would be used in a publishing profile. See " Deploy .NET Core apps with Visual Studio ".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM