Skip to content

Reference to Microsoft.NET.Sdk.Web not work #716

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
i-mark opened this issue Apr 22, 2023 · 4 comments
Closed

Reference to Microsoft.NET.Sdk.Web not work #716

i-mark opened this issue Apr 22, 2023 · 4 comments

Comments

@i-mark
Copy link

i-mark commented Apr 22, 2023

CleanShot 2023-04-22 at 12 37 12

dotnet script output

error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
error CS0103: The name 'WebApplication' does not exist in the current context

dotnet --info output

.NET SDK:
Version: 7.0.203
Commit: 5b005c19f5

Runtime Environment:
OS Name: Mac OS X
OS Version: 13.3
OS Platform: Darwin
RID: osx.13-arm64
Base Path: /usr/local/share/dotnet/sdk/7.0.203/

Host:
Version: 7.0.5
Architecture: arm64
Commit: 8042d61b17

.NET SDKs installed:
7.0.203 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

@charring
Copy link

charring commented May 4, 2023

I don't have an answer, but I am interested in this thread. It hadn't occurred to me that I could stand up a web server using dotnet-script, and I would be very interested to know if and how that can be accomplished.

@seesharper
Copy link
Collaborator

Try removing the shebang at the top of the script. I think we have a bug parsing the SDK reference

@charring
Copy link

charring commented May 5, 2023

Any comment at the top of the file will also break the parser:

//any comment here breaks it

#r "sdk:Microsoft.NET.Sdk.Web"

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Logging;

var app = WebApplication.Create();

app.Logger.LogInformation("The app started");

app.MapGet("/", () => "Hello world");

app.Run("http://localhost:5178");

Results in errors

The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

@i-mark
Copy link
Author

i-mark commented May 10, 2023

#!/usr/bin/env dotnet-script or #nullable enable before #r "sdk:Microsoft.NET.Sdk.Web" break the parser.

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