question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot add NuGet packages

See original GitHub issue

I am trying to use a NuGet package with dotnet-script. I have initialized a new script project as explained and added this into the main.csx file and restarted omnisharp. The using directive is always underlined with “Type or namespace could not be found”. I even do not see that any NuGet packages were downloaded.

#!/usr/bin/env dotnet-script
#r "nuget:GraphQlClientGenerator,0.7.3"
using GraphQLClientGenerator;

Here is the log

Starting OmniSharp server at 10/14/2020, 2:23:52 PM
    Target: /Users/x/repos/integration-service/Source/Clients/x/Generate

OmniSharp server started.
    Path: /Users/x/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/run
    PID: 50143

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.15.6 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "/Users/x/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/Users/x/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "/Users/x/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /Users/x/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/.msbuild/Current/Bin
            CscToolPath = /Users/x/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /Users/x/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/x/repos/integration-service/Source/Clients/x/Generate'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in '/Users/x/repos/integration-service/Source/Clients/x/Generate'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/x/repos/integration-service/Source/Clients/x/Generate'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Found 1 CSX files.
[info]: OmniSharp.Script.ScriptContextProvider
        Searching for compilation dependencies with the fallback framework of 'netcoreapp3.1'.
[fail]: OmniSharp.Script.ScriptContextProvider
        Failed to resolve compilation dependencies
[info]: OmniSharp.Script.ScriptContextProvider
        Unable to find dependency context for CSX files. Will default to non-context usage (Desktop CLR scripts).
[info]: OmniSharp.Script.ScriptProjectSystem
        Added CSX project '/Users/x/repos/integration-service/Source/Clients/x/Generate/main.csx' to the workspace.
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/x/repos/integration-service/Source/Clients/x/Generate' on host 49973.
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Solution initialized -> queue all documents for code analysis. Initial document count: 1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
filipwcommented, Oct 14, 2020

This is by design. dotnet-script will respect nuget.config to give you the ability to point to custom nuget feeds. Since NuGet 3.4 the nuget behavior is such that it will look in the project’s directory or “or any folder up to the drive root” to locate the config file https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior

0reactions
AndiRudicommented, Oct 14, 2020

I have added the official package source and it works. Not sure if above are still bugs to look at or if we can close this.

<packageSources>
    <add key="HangfirePro" value="..." />
    <add key="MyGet" value="..." />
    <add key="NuGet official package source" value="https://nuget.org/api/v2/" />
 </packageSources>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't Install Nuget Package
First, you have to make sure the version of NuGet Package Manager for Visual Studio 2013 is the latest version 2.12.0.817, not the...
Read more >
Can't install any nuget package in VS 2019 v16.6.0
workaround 1: My workaround is to manually type "install-package packageName" in the package manager console within Visual Studio. workaround 2: ...
Read more >
cannot install any packages - ERROR -https://packagesource
Please open Visual Studio > Tools > NuGet Package Manager > Package Manager Settings > Package Sources > check if any invalid package...
Read more >
Resolved - Can't install nuget packages. Button grayed out.
The error i get when I am trying to install packages through PK is: NuGet\Install-Package : Project 'Default' is not found. ... I...
Read more >
Unable to resolve dependencies of NuGet packages
Solution · Clear the NuGet cache files. You do this in the following way: In the toolbar of Visual Studio, navigate to Tools...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found