Description
We currently have a couple of issues (#636 , #602 and #588) which points back to the fact that it is currently not possible to specify the SDK being used by dotnet-script
.
Today we have a csproj
template file that looks like this.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
<WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
</Target>
</Project>
Say now that we wanted to spin up a minimal web api in a script.
This would require the project sdk to be set to <Project Sdk="Microsoft.NET.Sdk.Web">
, but since that is basically "hardcoded" into the template we currently don't have a way for specifying the SDK.
For this to work not only during execution, but also from the OmniSharp side we would need something that can be read when resolving dependencies (runtime and compilation).
Since <Project Sdk="Microsoft.NET.Sdk">
basically is a way to specify which assemblies from the shared framework to be pulled in, it might make sense to extend upon the #r
directive here.
Suggested syntax
#r "sdk:Microsoft.NET.Sdk.Web"
We will then use the given sdk when creating the csproj file used for restore and dependency resolving.
The default would be Microsoft.NET.Sdk
as before unless specified in the #r
directive
csproj file with #r "sdk:Microsoft.NET.Sdk.Web"
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
<WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
</Target>
</Project>
@filipw Thoughts? 😃