❔ Is it possible to change a project sdk from Microsoft.NET.Sdk to Microft.net.sdk.net?

I'm completely new to c# and .NET so apologies if this doesn't make sense. If a project csproj file has the following <project sdk="Microsoft.NET.Sdk">, this means the project is your standard .NET Core project type without any extra features like Web or Blazor right? But if I wanted to use features from ASP.NET within this project, how would I do it? Do I just change my sdk from Microsoft.NET.Sdk to Microsoft.NET.Sdk.Net? Or would I need to run a command like Install-Package/dotnet add package?
10 Replies
Anton
Anton2y ago
that sdk line is just importing Microsoft.NET.Sdk.props at the top and Microsoft.NET.Sdk.targets at the bottom, which contain some common things including nuget support, some directory properties and hooks up the compiler. to add packages, you add PackageReference nodes it's either done from vs console, through ui, through dotnet cli, or by just editing the csproj file
TradingRaws4SeoulObjectStoryRaws
So if I just added
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
to my csproj file, would the Swashbuckle.AspNetCore package just be downloaded(?)/used when I try building the app? And would something similar would happen if I changed <project sdk="Microsoft.NET.Sdk"> to <project sdk="Microsoft.NET.Sdk.Web">?
Anton
Anton2y ago
yes ig web has some more stuff needed for web apps the properties and launch jsons things I would guess but fundamentally it just includes the props and the targets files with that name go off of a template
TradingRaws4SeoulObjectStoryRaws
Interesting. Thanks for the help! It seems like the csproj file is kinda like a package.json file in NodeJS
Anton
Anton2y ago
it's MSBuild
Angius
Angius2y ago
Yeah, except XML because Microsoft loves their <>s
TradingRaws4SeoulObjectStoryRaws
x'D ahhh I see
Anton
Anton2y ago
MSBuild is the engine that implements that dotnet cli is a wrapper for msbuild for the most part
TradingRaws4SeoulObjectStoryRaws
I feel like all this c#/.NET is starting to come together more. Thanks for all the help mate heartowo
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.