bjorkstromm / depends

Tool for generating dependency trees for .NET projects
MIT License
537 stars 41 forks source link

Crashes when analysing classic .net framework projects. #3

Closed Tewr closed 4 years ago

Tewr commented 6 years ago

Is this project only for .net core projects? If that is the case, you might want to mention that in your readme, and/or catch the exception. My v4.5.1 application crashes with the following exception:

Repro:

> git clone https://github.com/Tewr/DomainPasswd.git
>cd .\Passwd\
> dotnet-depends.exe -v Trace -f v4.5.2

Exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Unable to load project.
   at Depends.Core.DependencyAnalyzer.Analyze(String projectPath, String framework) in C:\Users\mb\src\gh\depends\src\Depends.Core\DependencyAnalyzer.cs:line 59
   at Depends.Program.OnExecute() in C:\Users\mb\src\gh\depends\src\Depends\Program.cs:line 61
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.Invoke(MethodInfo method, Object instance, Object[] arguments) in C:\projects\commandlineutils\src\CommandLineUtils\Conventions\ExecuteMethodConvention.cs:line 86
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context) in C:\projects\commandlineutils\src\CommandLineUtils\Conventions\ExecuteMethodConvention.cs:line 64
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext() in C:\projects\commandlineutils\src\CommandLineUtils\Conventions\ExecuteMethodConvention.cs:line 25
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass126_0.<OnExecute>b__0() in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.cs:line 505
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](CommandLineContext context) in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.Execute.cs:line 31
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](IConsole console, String[] args) in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.Execute.cs:line 97
   at Depends.Program.Main(String[] args) in C:\Users\mb\src\gh\depends\src\Depends\Program.cs:line 16

Log:

info: Buildalyzer.ProjectAnalyzer[0]
      Build started 10.08.2018 13:20:29.

info: Buildalyzer.ProjectAnalyzer[0]
      __________________________________________________

info: Buildalyzer.ProjectAnalyzer[0]
      Project "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" (Restore target(s)):

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Target _FilterRestoreGraphProjectInputItems:

info: Buildalyzer.ProjectAnalyzer[0]
          __________________________________________________

info: Buildalyzer.ProjectAnalyzer[0]
          Project "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" is building "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" (_IsProjectRestoreSupported target(s)):

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Target _GetAllRestoreProjectPathItems:

info: Buildalyzer.ProjectAnalyzer[0]
          __________________________________________________

info: Buildalyzer.ProjectAnalyzer[0]
          Project "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" is building "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" (_GenerateRestoreProjectPathWalk target(s)):

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
          __________________________________________________

info: Buildalyzer.ProjectAnalyzer[0]
          Project "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" is building "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" (_IsProjectRestoreSupported target(s)):

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Target _GenerateRestoreGraph:

info: Buildalyzer.ProjectAnalyzer[0]
          __________________________________________________

info: Buildalyzer.ProjectAnalyzer[0]
          Project "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" is building "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" (_GenerateRestoreGraphProjectEntry target(s)):

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
          __________________________________________________

info: Buildalyzer.ProjectAnalyzer[0]
          Project "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" is building "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" (_GenerateProjectRestoreGraph target(s)):

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Target Restore:

info: Buildalyzer.ProjectAnalyzer[0]
          Nothing to do. None of the projects specified contain packages to restore.

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Build succeeded.

info: Buildalyzer.ProjectAnalyzer[0]
          0 Warning(s)

info: Buildalyzer.ProjectAnalyzer[0]
          0 Error(s)

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Time Elapsed 00:00:00.62

info: Buildalyzer.ProjectAnalyzer[0]
      Build started 10.08.2018 13:20:30.

info: Buildalyzer.ProjectAnalyzer[0]
      __________________________________________________

info: Buildalyzer.ProjectAnalyzer[0]
      Project "C:\temp\dotnetdeptest\DomainPasswd\Passwd\DomainPasswd.csproj" (Clean;Build target(s)):

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Target CoreClean:

info: Buildalyzer.ProjectAnalyzer[0]
          Deleting file "C:\temp\dotnetdeptest\DomainPasswd\Passwd\bin\Debug\DomainPasswd.exe.config".

info: Buildalyzer.ProjectAnalyzer[0]
          Deleting file "C:\temp\dotnetdeptest\DomainPasswd\Passwd\obj\Debug\DomainPasswd.csproj.CoreCompileInputs.cache".

info: Buildalyzer.ProjectAnalyzer[0]
      Target ResolveAssemblyReferences:

info: Buildalyzer.ProjectAnalyzer[0]
          Primary reference "CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL".

info: Buildalyzer.ProjectAnalyzer[0]
          C:\Program Files\dotnet\sdk\2.1.300\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

info: Buildalyzer.ProjectAnalyzer[0]
                  For SearchPath "{HintPathFromItem}".

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  For SearchPath "{TargetFrameworkDirectory}".

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\CommandLine.winmd", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\CommandLine.dll", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\CommandLine.exe", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\CommandLine.winmd", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\CommandLine.dll", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\CommandLine.exe", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.5.2,AssemblyFoldersEx}".

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered AssemblyFoldersEx locations.

info: Buildalyzer.ProjectAnalyzer[0]
                  For SearchPath "{GAC}".

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "{GAC}\CommandLine.winmd", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "{GAC}\CommandLine.dll", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "{GAC}\CommandLine.exe", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  For SearchPath "{RawFileName}".

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered treating "CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL" as a file name, but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  For SearchPath "bin\Debug\".

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "bin\Debug\CommandLine.winmd", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "bin\Debug\CommandLine.dll", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
                  Considered "bin\Debug\CommandLine.exe", but it didn't exist.

info: Buildalyzer.ProjectAnalyzer[0]
      Done building target "ResolveAssemblyReferences" in project "DomainPasswd.csproj".

info: Buildalyzer.ProjectAnalyzer[0]
      Target GenerateTargetFrameworkMonikerAttribute:

info: Buildalyzer.ProjectAnalyzer[0]
        Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.

info: Buildalyzer.ProjectAnalyzer[0]
      Target CoreCompile:

info: Buildalyzer.ProjectAnalyzer[0]
          C:\Program Files\dotnet\sdk\2.1.300\Roslyn\bincore\csc.dll /noconfig /unsafe+ /nowarn:1701,1702 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.DirectoryServices.AccountManagement.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.DirectoryServices.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\DomainPasswd.exe /subsystemversion:6.00 /resource:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.DirectoryServices.dll",DomainPasswd.DirectoryServices.System.DirectoryServices.dll /resource:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.DirectoryServices.AccountManagement.dll",DomainPasswd.DirectoryServices.System.DirectoryServices.AccountManagement.dll /resource:..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll,DomainPasswd.CommandLine.dll /target:exe /utf8output CommandLinePasswordChangerSource.cs SystemDirectoryServicesImpl\PrincipalDomainUser.cs IChangePasswordOptions.cs IDomainContext.cs IDomainContextFactory.cs IDomainUser.cs IPasswordChangerSource.cs PasswordChanger.cs PasswordMismatchException.cs SystemDirectoryServicesImpl\PrincipalDomainContext.cs SystemDirectoryServicesImpl\PrincipalDomainContextFactory.cs Program.cs ProgramOptions.cs Properties\AssemblyInfo.cs "C:\Users\Knutsson\AppData\Local\Temp\.NETFramework,Version=v4.5.2.AssemblyAttributes.cs"

info: Buildalyzer.ProjectAnalyzer[0]
      Target _CopyAppConfigFile:

info: Buildalyzer.ProjectAnalyzer[0]
          Copying file from "App.config" to "bin\Debug\DomainPasswd.exe.config".

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Done building project "DomainPasswd.csproj".

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Build succeeded.

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      C:\Program Files\dotnet\sdk\2.1.300\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

info: Buildalyzer.ProjectAnalyzer[0]
          1 Warning(s)

info: Buildalyzer.ProjectAnalyzer[0]
          0 Error(s)

info: Buildalyzer.ProjectAnalyzer[0]

info: Buildalyzer.ProjectAnalyzer[0]
      Time Elapsed 00:00:00.42
bjorkstromm commented 6 years ago

@Tewr yes, the tools currently only supports new csproj format. But the engine (aka Buildalyzer) supports all varieties of projects. I will add this into backlog and look into it.