Open marvfinsy opened 1 year ago
Same issue, SDK is installed 🤷♂️
Version : 1.4.0
Install location : /Users/slavin/.dotnet/tools/.store/dotnet-script/1.4.0/dotnet-script/1.4.0/tools/net7.0/any
Target framework : net7.0
.NET Core version : 7.0.5
Platform identifier : osx
Runtime identifier : osx-x64
it works on my machine™️ 😀
please run dotnet script {your csx file} --verbosity d --no-cache
and post the output here.
➜ dotnet script index.csx --verbosity d --no-cache
dbug: Dotnet.Script.Core.Commands.ExecuteScriptCommand[0]
The script /Users/slavin/source/test/index.csx was executed with the '--no-cache' flag. Skipping cache.
info: Dotnet.Script.Core.ScriptCompiler[0]
Current runtime is 'osx'.
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
Creating project file for /Users/slavin/source/test/index.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptParser[0]
Parsing /Users/slavin/source/test/index.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
Project file saved to /Users/slavin/Library/Caches/dotnet-script/Users/slavin/source/test/net7.0/script.csproj
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup></ItemGroup>
<Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
<WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
</Target>
</Project>
dbug: Dotnet.Script.DependencyModel.Context.DotnetRestorer[0]
Restoring /Users/slavin/Library/Caches/dotnet-script/Users/slavin/source/test/net7.0/script.csproj using the dotnet cli. RuntimeIdentifier : osx-x64 NugetConfigFile: /Users/slavin/.nuget/NuGet/NuGet.Config
dbug: Dotnet.Script.DependencyModel.Context.ProfiledRestorer[0]
Restoring /Users/slavin/Library/Caches/dotnet-script/Users/slavin/source/test/net7.0/script.csproj took 1097ms
dbug: Dotnet.Script.Core.ScriptCompiler[0]
Configuration/Optimization mode: Debug
/Users/slavin/source/test/index.csx(5,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
/Users/slavin/source/test/index.csx(7,9): error CS0103: The name 'WebApplication' does not exist in the current context
do you have the #r "sdk:Microsoft.NET.Sdk.Web"
directive on top of your file?
according to the logs, the script uses <Project Sdk="Microsoft.NET.Sdk">
instead of <Project Sdk="Microsoft.NET.Sdk.Web">
which is why the ASP.NET Core dependencies cannot be found
@filipw yes, there seem to be some kind of miss match happening. Here's the content of the script:
#!/usr/bin/env dotnet-script
#r "sdk:Microsoft.NET.Sdk.Web"
using Microsoft.AspNetCore.Builder;
var a = WebApplication.Create();
a.MapGet("/", () => "Hello world");
a.Run();
oh I see the bug now. it's the shebang on top that breaks it.
if you remove #!/usr/bin/env dotnet-script
it will work.
Likely a parser problem.
oh I see the bug now. it's the shebang on top that breaks it. if you remove
#!/usr/bin/env dotnet-script
it will work.Likely a parser problem.
thanks Filip, that's exactly it 👍
I finally got a chance to get back to this. Yes that seems to be the problem. Also i noticed that the "sdk directive" must be on the first line of the script. If i skip a line putting it on line 2, i also get the AspCore dependencies not found.
Noticed in Visual Code Intellisense complains those dependencies are not available but the code does run. Is that because the
Is there a template that's used that i can add this so when the .csproj file is being built that tag will be there?
I would like the winforms / wpf sdk to be usable as well with this.
Any fix for losing Intellisense and code completion when referencing a sdk?
In the Specifying an sdk u show an example creating a web app:
r "sdk:Microsoft.NET.Sdk.Web"
using Microsoft.AspNetCore.Builder;
var a = WebApplication.Create(); a.MapGet("/", () => "Hello world"); a.Run();
====
I get error saying 'AspNetCore' does not exist in namespace 'Microsoft'.
Has this changed?
environment: Mac osx ARM i have Core6 and Core7 Frameworks installed. Currently using Core7.
I created project using command as shown in doc $> dotnet script init
thx ~Marvin Foster mmarvb7@gmail.com or marvinfoster@finsync.com