Skip to content
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

The type 'Action<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=5.0.0.0 ...' #129

Closed
augustoproiete opened this issue Mar 7, 2021 · 17 comments
Labels
Milestone

Comments

@augustoproiete
Copy link
Member

Originally reported by @rmbrunet on #127 (comment)

The type 'Action<>' is defined in an assembly that is not referenced. You must add a reference to assembly
'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. [build.cake]csharp(CS0012)

The type 'Func<,>' is defined in an assembly that is not referenced. You must add a reference to assembly
'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. [build.cake]csharp(CS0012)
OmniSharp log... (click to expand)

Starting OmniSharp server at 3/7/2021, 2:55:22 PM
Target: c:\augustoproiete\cake\test-bakery

OmniSharp server started.
Path: c:\Users\augustoproiete.vscode\extensions\ms-dotnettools.csharp-1.23.9.omnisharp\1.37.8-beta.4\OmniSharp.exe
PID: 27192

Starting OmniSharp on Windows 6.2.9200.0 (x64)
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2019 16.8.31019.35 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
2: StandAlone 16.9.0 - "c:\Users\augustoproiete.vscode\extensions\ms-dotnettools.csharp-1.23.9.omnisharp\1.37.8-beta.4.msbuild\Current\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2019 16.8.31019.35 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
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.Cake.CakeProjectSystem
Detecting Cake files in 'c:\augustoproiete\cake\test-bakery'.
info: OmniSharp.Cake.CakeProjectSystem
Found 1 Cake files.
info: OmniSharp.Cake.Services.CakeScriptService
Using Cake.Bakery at c:\augustoproiete\cake\test-bakery\tools\Cake.Bakery\tools\Cake.Bakery.exe
info: OmniSharp.Cake.CakeProjectSystem
Added Cake project 'c:\augustoproiete\cake\test-bakery\build.cake' to the workspace.
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in 'c:\augustoproiete\cake\test-bakery'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\augustoproiete\cake\test-bakery'.
info: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\augustoproiete\cake\test-bakery' on host 11084.
Received response for /quickinfo but could not find request.

Repro steps:

  • Install VS Code extension (latest)
  • Install OmniSharp (latest) (i.e. "omnisharp.path": "latest")
  • Open VS Code on a folder
  • Install Cake .NET Tool (Global)
  • Install Intellisense support (Bakery 0.6.1)
  • Restart OmniSharp

N.B.: The issue goes away if I install the .NET Core runner and restart OmniSharp as reported by @rmbrunet

@devlead
Copy link
Member

devlead commented Mar 7, 2021

Could this be related to dotnet/vscode-csharp#3289 ?

@augustoproiete
Copy link
Member Author

augustoproiete commented Mar 7, 2021

Could this be related to OmniSharp/omnisharp-vscode#3289 ?

I tried the workaround suggested there and it didn't seem to have any effect:

{
   "MSBuild": {
       "UseLegacySdkResolver": true
   }
}

@rmbrunet
Copy link

rmbrunet commented Mar 7, 2021

FWIW, the Cake.Tool is installed locally, per recommendation, and globally for intellisense.

@bjorkstromm
Copy link
Member

Could this be related to OmniSharp/omnisharp-vscode#3289 ?

No, Cake doesn't rely on MSBuild stuff. This is probably because .NET 5 deps are missing here.

private ISet<FilePath> GetDefaultReferences(DirectoryPath root)

This might be tricky to solve, since Bakery is currently running on .NET 4.6.

@augustoproiete
Copy link
Member Author

augustoproiete commented Mar 7, 2021

I did a few tests, and the problem seems to have been introduced with Cake 1.0.0 with the addition of the net5.0 target.

Cake.Bakery resolves Cake.dll as the following:

pattern = string.Concat(dotnetCakePath.FullPath, "/.store/**/Cake.dll");
var cakeDllPath = _globber.GetFiles(pattern).FirstOrDefault();

Before Cake 1.0, it resolved to:

  • %USERPROFILE%/.dotnet/tools/.store/cake.tool/0.38.5/cake.tool/0.38.5/tools/netcoreapp2.1/any/Cake.dll

Starting with Cake 1.0, it resolves to:

  • %USERPROFILE%/.dotnet/tools/.store/cake.tool/1.0.0/cake.tool/1.0.0/tools/net5.0/any/Cake.dll

@devlead
Copy link
Member

devlead commented Mar 7, 2021

So we need a Bakery Tool 🤔

@bjorkstromm
Copy link
Member

Yes, either investigate moving Bakery to .NET 5 (will require changes on O# side on how tool is invoked) or make sure Bakery resolves a Cake.dll from Cake.Tool which is netstandard2.0 compatible. Problem seems to be that Cake.Core and Cake.Common targets ns2.0 and net5.. When the net5 version of Cake.Tool is resolved (as @augustoproiete pointed out), it will only find a Cake.Core and Cake.Common built for net5.

Why Cake.Core and Cake.Common targets net5 is something that I don't know. IMO ns2.0 should have been sufficient.

@augustoproiete
Copy link
Member Author

As an intermediary fix, should we release a new version of Cake.Bakery that resolves Cake.dll to netcoreapp2.1/any/Cake.dll to get it to work?

@bjorkstromm
Copy link
Member

As an intermediary fix, should we release a new version of Cake.Bakery that resolves Cake.dll to netcoreapp2.1/any/Cake.dll to get it to work?

Preferably the netcoreapp3.1 since that's LTS, and will also contain the ns2.0 versions of Cake.Core and Cake.Common

@bjorkstromm
Copy link
Member

I mean, we might be more likely to drop net core 2.x monikers from Cake.Tool in future versions than net core 3.1.

@devlead
Copy link
Member

devlead commented Mar 7, 2021

But shouldn't a net46 binary resolve the net46 assemblies?

@augustoproiete
Copy link
Member Author

I mean, we might be more likely to drop net core 2.x monikers from Cake.Tool in future versions than net core 3.1.

@bjorkstromm Sounds good to me, if netcoreapp3.1 will work just as well (via netstandard2.0).

But shouldn't a net46 binary resolve the net46 assemblies?

@devlead What do you mean? We don't include net46 assemblies with the .NET Tool

augustoproiete added a commit to augustoproiete-forks/cake-build--bakery that referenced this issue Mar 7, 2021
…etcoreapp3.1

Bakery currently needs Cake.Core and Cake.Common targeting netstandard2.0 only
cake-build#129 (comment)
@devlead
Copy link
Member

devlead commented Mar 8, 2021

But shouldn't a net46 binary resolve the net46 assemblies?

@devlead What do you mean? We don't include net46 assemblies with the .NET Tool

I mean, if Bakery is a net46 app loading netcoreapp binaries can be a hit and miss with issues as what it "legally" can load netstandard or net46 even if Cake.Core would happen to be netstandard addins/assemblies loaded probably won't , so maybe better would be a Cake.Bakery.Tool that could target the same frameworks as Cake.Tool, installing it locally would give exe that could be executed that would fully support netcoreapp 2.x/3.x, and net5.0

@bjorkstromm
Copy link
Member

Cake.Bakery doesn't load (via reflection) Cake.Core nor Cake.Common, it only resolves the paths which are fed to Roslyn (OmniSharp-Roslyn) as Metadatareferences when script is compiled. Resolving a path for a ns2.0 built DLL will work (and has worked), but resolving a net5 built DLL will not work.

In the long run, supporting net5 (or preferably net6) is optimal. But that will require more work, both on O# side and Bakery side. How much, I don't know, "here be dragons".

@devlead
Copy link
Member

devlead commented Mar 8, 2021

Ok can't e just ship Core / Common with bakery then?

@bjorkstromm
Copy link
Member

Ok can't e just ship Core / Common with bakery then?

Sure, but the original reasoning behind this behavior was to provide intellisense for the Cake version that the user used (e.g. was installed in tools folder). Now with global tool etc (and Cake v1.x) this might not be needed anymore. Shipping latest Cake.Core a Cake.Common with Bakery might be good-enough solution.

augustoproiete added a commit to augustoproiete-forks/cake-build--bakery that referenced this issue Mar 8, 2021
…etcoreapp3.1

Bakery currently needs Cake.Core and Cake.Common targeting netstandard2.0 only
cake-build#129 (comment)
@gep13 gep13 added this to the 0.6.2 milestone Mar 8, 2021
gep13 pushed a commit that referenced this issue Mar 8, 2021
Bakery currently needs Cake.Core and Cake.Common targeting netstandard2.0 only
#129 (comment)
gep13 added a commit that referenced this issue Mar 8, 2021
…/0.6.2

* force-netcoreapp3-1-for-dotnet-global-tool:
  (GH-129) When using .NET Global tool, resolve Cake.dll to netcoreapp3.1
@gep13 gep13 closed this as completed Mar 8, 2021
gep13 added a commit that referenced this issue Mar 8, 2021
* hotfix/0.6.2:
  (GH-129) When using .NET Global tool, resolve Cake.dll to netcoreapp3.1
gep13 added a commit that referenced this issue Mar 8, 2021
* hotfix/0.6.2:
  (GH-129) When using .NET Global tool, resolve Cake.dll to netcoreapp3.1
@cake-build-bot
Copy link

🎉 This issue has been resolved in version 0.6.2 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

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