8000 (Feature proposal) Ability to specify SDK · Issue #689 · dotnet-script/dotnet-script · GitHub
[go: up one dir, main page]

Skip to content

(Feature proposal) Ability to specify SDK #689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
seesharper opened this issue Sep 27, 20 8000 22 · 4 comments
Closed

(Feature proposal) Ability to specify SDK #689

seesharper opened this issue Sep 27, 2022 · 4 comments

Comments

@seesharper
Copy link
Collaborator
seesharper commented Sep 27, 2022

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

@filipw
Copy link
Member
filipw commented Sep 28, 2022

That makes sense to me, we would still default to Microsoft.NET.Sdk. The sdk prefix (vs the nuget) is a good idea, especially as in the csproj files, the SDKs, despite being nuget packages themselves, are also given a "special treatment".

I also think this should be quite easy to implement (unless I am being a short-sighted).

@ihqtim
Copy link
ihqtim commented Nov 20, 2022

Is there any workaround I could use today that would allow dotnet-script to work with Microsoft.NET.Sdk.Web? Specifically, want dynamically generated scripts to start a small web server to host some short-lived API routes.

@seesharper
Copy link
Collaborator Author

We will include this feature as part of the upcoming release. #694

@seesharper
Copy link
Collaborator Author

Closed by #694

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0