Skip to content

(Feature proposal) Ability to specify SDK #689

Closed
@seesharper

Description

@seesharper

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 csprojtemplate 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? 😃

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy