Building .netstandard library on linux using command line options

Multi tool use
Building .netstandard library on linux using command line options
How to build a project targeted to netstandard on linux using command line options. Can MSBUILD/csc be used to build the files on linux.
I had googled and found that .NET Core sdk provides "dotnet" tool to compile the code.
But to compile a code which has to be targeted to "netstandard" what command line tool has to be used which comes along the sdk.
1 Answer
1
The information on the target framework can simply be indicated in the .csproj
file.
.csproj
Then you execute dotnet publish
or dotnet build
to generate binaries.
dotnet publish
dotnet build
For instance, here is a MyProject.csproj
example of a project that has several target framework for .NET standard :
MyProject.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard1.6;netstandard1.4</TargetFrameworks>
<RootNamespace>MyName.MyProject</RootNamespace>
<AssemblyName>MyName.MyProject</AssemblyName>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Configurations>Debug;Release</Configurations>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
....
</Project>
If I want the .NET standard 2.0 output I can execute :
dotnet publish MyProject.csproj --framework netstandard2.0
(with maybe other unrelated options)
dotnet publish MyProject.csproj --framework netstandard2.0
Note: usually, you need only one target framework.
TargetFrameworks
yes, you are right. In one particular project example I actually needed to have several target, but usually there is only one needed as you said.
– Pac0
Jul 3 at 7:36
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
BTW, unless the code base requires conditional compilation, it is less likely to need many .NET Standard versions in
TargetFrameworks
.– Lex Li
Jul 3 at 1:34