phmonte / Buildalyzer

A utility to perform design-time builds of .NET projects without having to think too hard about it.
MIT License
593 stars 94 forks source link

NullReferenceException building .NET 5 WPF VB project #150

Closed Sergey-Vlasov closed 2 years ago

Sergey-Vlasov commented 3 years ago

With .NET 5 RC2 installed.

dotnet new wpf -lang VB

using System;
using Buildalyzer;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            IProjectAnalyzer analyzer = (new AnalyzerManager()).GetProject(@"m:\temp\x\x.vbproj");
            IAnalyzerResults results = analyzer.Build();
        }
    }
}
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Buildalyzer.Construction.ProjectFile.<>c__DisplayClass13_0.<get_RequiresNetFramework>b__2(String i) in m:\temp\downloads\Buildalyzer-main\src\Buildalyzer\Construction\ProjectFile.cs:line 87
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at Buildalyzer.Construction.ProjectFile.<>c.<get_RequiresNetFramework>b__13_0(XElement x) in m:\temp\downloads\Buildalyzer-main\src\Buildalyzer\Construction\ProjectFile.cs:line 87
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at Buildalyzer.Construction.ProjectFile.get_RequiresNetFramework() in m:\temp\downloads\Buildalyzer-main\src\Buildalyzer\Construction\ProjectFile.cs:line 87
   at Buildalyzer.Environment.EnvironmentFactory.GetBuildEnvironment(String targetFramework, EnvironmentOptions options) in m:\temp\downloads\Buildalyzer-main\src\Buildalyzer\Environment\EnvironmentFactory.cs:line 44
   at Buildalyzer.Environment.EnvironmentFactory.GetBuildEnvironment(String targetFramework) in m:\temp\downloads\Buildalyzer-main\src\Buildalyzer\Environment\EnvironmentFactory.cs:line 31
   at Buildalyzer.ProjectAnalyzer.Build(String targetFramework) in m:\temp\downloads\Buildalyzer-main\src\Buildalyzer\ProjectAnalyzer.cs:line 128
   at Buildalyzer.ProjectAnalyzer.Build() in m:\temp\downloads\Buildalyzer-main\src\Buildalyzer\ProjectAnalyzer.cs:line 147
daveaglick commented 3 years ago

Thanks for the bug reports - keep them coming. I haven't actually played with .NET 5 much but it looks like there's some breaks somewhere. I'm not totally surprised - the MSBuild tool chain seems delicate and breaks pretty much every major build.

daveaglick commented 3 years ago

Do you know if a .NET 5 WPF C# project works? Trying to figure out if this problem is specific to VB or if it's a more broad .NET 5 issue.

Sergey-Vlasov commented 3 years ago

.NET 5 WPF C# project works fine.

daveaglick commented 2 years ago

I think this is resolved in #207 courtesy of @cslong - at a minimum an AnalyzerResult is now created for Visual Basic projects (and tested via unit test). Hopefully the issue here was more one of VB support and not WPF support (since a C# WPF project works). I'll close this issue, but please open a new one if it looks like there are still problems with VB support (though my ability to help will be limited since I don't know the first thing about VB or VB projects).