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

ProjectAnalyzer.Compile failed internally and return null in dotnet-sdk-2.1.300 #54

Closed
itn3000 opened this issue Jun 8, 2018 · 5 comments

Comments

@itn3000
Copy link
Contributor

itn3000 commented Jun 8, 2018

Environment

my dotnet --info output;

.NET Core SDK (global.json を反映):
 Version:   2.1.300
 Commit:    adab45bf0c

ランタイム環境:
 OS Name:     Windows
 OS Version:  6.3.9600
 OS Platform: Windows
 RID:         win81-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.300\

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

.NET Core SDKs installed:
  1.0.0-preview2-003118 [C:\Program Files\dotnet\sdk]
  1.0.0-preview2-003121 [C:\Program Files\dotnet\sdk]
  1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
  1.0.0-preview2-003133 [C:\Program Files\dotnet\sdk]
  1.0.0-preview2-003156 [C:\Program Files\dotnet\sdk]
  1.0.0-preview2-1-003177 [C:\Program Files\dotnet\sdk]
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.0.0-preview1-005977 [C:\Program Files\dotnet\sdk]
  2.0.0 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.3 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.100 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.300-rc1-008673 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0-rc1-final [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0-rc1-final [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.0-rc2-3002702 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0-preview1-002111-00 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0-rc1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Steps to reproduce

  1. clone https://github.com/itn3000/buildalyzer-failed-sdk-2.1.300
  2. cd to buildalyzertest
  3. run dotnet run -- ../sampleclass/sampleclass.csproj

Expected result

output compilation results(success) and project items and exit.

Actual result

with dotnet-core-sdk 2.1(2.1.300), output compilation results(failed) and output project instance is null then exit.
but dotnet-core-sdk 2.0(2.1.4), expected results were output.

Workaround

add following packages into project that using Buildalyzer.

  • NuGet.Common
  • NuGet.ProjectModel
@daveaglick
Copy link
Collaborator

Thanks - pretty sure this is related to #49 - hoping to figure out a resolution soon.

@daveaglick
Copy link
Collaborator

Actually, I added the two NuGet packages you suggested directly to Buildalyzer and it works now. Thanks!

That makes sense too - I think the underlying problem is that they stopped shipping NuGet packages alongside the SDK. I had suggested some other more complicated solutions in #49 (like overriding the assembly loader), but I'm very tempted to just add the package references and be done with it.

@daveaglick
Copy link
Collaborator

A new version 0.5.0 is hitting NuGet now - can you please take it for a spin and let me know if it resolves this issue for you?

@itn3000
Copy link
Contributor Author

itn3000 commented Jun 18, 2018

Buildalyzer-0.5.0 resolves my problem, thank you for updating.
Additional Info: I found another workaround which use System.Runtime.Loader.AssemblyContext.Default.LoadFromAssemblyPath before project compilation.
But this way still remains "what assemblies should I load?" problem.
AssemblyContext.Resolved event was not fired when required NuGet.Versioning.

@daveaglick
Copy link
Collaborator

Yeah, I think the best bet is to directly depend on the NuGet packages. Unfortunately this increases the dependency surface of Buildalyzer, but none of the alternatives seem as stable to me.

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

2 participants