In .net framework i can use csc.exe to compile one cs file to a dll file.
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc.exe /t:library /out:MyCScode.dll *.cs /debug /r:System.dll /r:System.Web.dll /r:System.Data.dll /r:System.Xml.dll
How can i do this in dotnetcore ?
At a minimum you'll need a .csproj file with this content:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
That is assuming you'll be targeting netstandard2.0 which would allow your library to run on .NET Framework 4.6.1, .NET Core 2.0 and any other runtime that implements the standard. And also have downloaded the .NET Core 2.0 SDK.
Unlike the old csproj, there's no need to add the individual .cs files to compile them.
So on a directory with such content:
Simply running: dotnet build will output a dll at the bin folder as you'd expect.
It's worth mentioning that the .NET Core CLI have templates for ASP.NET Core, class library, xUnit test project, etc:
$ dotnet new classlib
Would give you the csproj and a first class file.
You can use dotnet build to build your project for asp.net core
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With