Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

ApiIntersect - Ignore unresolved assemblies by default #163

Merged
merged 1 commit into from
Aug 26, 2018

Conversation

mrward
Copy link
Member

@mrward mrward commented Jul 20, 2018

Running ApiIntersect on an Android project will fail to resolve the
MonoAndroid assembly. Since this assembly is not required and should
not be included in the generated classes a new argument has been
added to the ApiIntersect tool so unresolved assemblies can be
ignored and the classes can be generated without an exception
being thrown. This prevents the ApiIntersect.exe error on building:

NuGet.Build.Packaging.ReferenceAssembly.targets(3,3):
Error MSB6006: "ApiIntersect.exe" exited with code 1. (MSB6006)

With verbose msbuild logging the ApiIntersect crash is:

  Unhandled Exception:
  System.Exception: Could not resolve Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
    at ApiIntersect.FrameworkAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x0001b] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.FrameworkAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ICSharpCode.Decompiler.Ast.Transforms.IntroduceUsingDeclarations.Run (ICSharpCode.NRefactory.CSharp.AstNode compilationUnit) [0x00142] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.Transforms.TransformationPipeline.RunTransformationsUntil (ICSharpCode.NRefactory.CSharp.AstNode node, System.Predicate`1[T] abortCondition, ICSharpCode.Decompiler.DecompilerContext context) [0x0002c] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.AstBuilder.RunTransformations (System.Predicate`1[T] transformAbortCondition) [0x00000] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.AstBuilder.RunTransformations () [0x00000] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ApiIntersect.MainClass.DumpTypes (System.Collections.Generic.List`1[T] types, System.String baseDir) [0x000a7] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.MainClass.Process (System.Collections.Generic.List`1[T] intersections, System.Collections.Generic.List`1[T] exclusions, Mono.Cecil.ReaderParameters readerParameters, System.String outputPath) [0x00319] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.MainClass.Main (System.String[] args) [0x0039f] in <aac3e0d5bcd4473a96e385115da49b96>:0

Note that the missing assembly references will be reported by MSBuild as warnings so this information is not hidden from the user.

Running ApiIntersect on an Android project will fail to resolve the
MonoAndroid assembly. Since this assembly is not required and should
not be included in the generated classes a new argument has been
added to the ApiIntersect tool so unresolved assemblies can be
ignored and the classes can be generated without an exception
being thrown. This prevents the ApiIntersect.exe error on building:

NuGet.Build.Packaging.ReferenceAssembly.targets(3,3):
Error MSB6006: "ApiIntersect.exe" exited with code 1. (MSB6006)

With verbose msbuild logging the ApiIntersect crash is:

  Unhandled Exception:
  System.Exception: Could not resolve Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
    at ApiIntersect.FrameworkAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x0001b] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.FrameworkAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ICSharpCode.Decompiler.Ast.Transforms.IntroduceUsingDeclarations.Run (ICSharpCode.NRefactory.CSharp.AstNode compilationUnit) [0x00142] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.Transforms.TransformationPipeline.RunTransformationsUntil (ICSharpCode.NRefactory.CSharp.AstNode node, System.Predicate`1[T] abortCondition, ICSharpCode.Decompiler.DecompilerContext context) [0x0002c] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.AstBuilder.RunTransformations (System.Predicate`1[T] transformAbortCondition) [0x00000] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ICSharpCode.Decompiler.Ast.AstBuilder.RunTransformations () [0x00000] in <37b5ad8a7a94479fbc5b574a8fc6281a>:0
    at ApiIntersect.MainClass.DumpTypes (System.Collections.Generic.List`1[T] types, System.String baseDir) [0x000a7] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.MainClass.Process (System.Collections.Generic.List`1[T] intersections, System.Collections.Generic.List`1[T] exclusions, Mono.Cecil.ReaderParameters readerParameters, System.String outputPath) [0x00319] in <aac3e0d5bcd4473a96e385115da49b96>:0
    at ApiIntersect.MainClass.Main (System.String[] args) [0x0039f] in <aac3e0d5bcd4473a96e385115da49b96>:0
@mrward mrward requested a review from kzu July 20, 2018 12:57
@mrward
Copy link
Member Author

mrward commented Jul 24, 2018

The build failure seems to have been happening with other builds and seems unrelated to this change.

2167               NuGet.Build.Packaging.given_a_library_with_private_assets_reference.when_getting_package_contents_then_contains_private_lib_assets_as_primary_output_and_also_package_reference [FAIL]
2168               Assert.Contains() Failure
2169               Not found: (filter expression)
2170               In value:  TaskItem[] [C:\projects\nuget-build-packaging\src\Build\NuGet.Build.Packaging.Tests\bin\Release\Scenarios\given_a_library_with_private_assets_reference\bin\a\a.dll, C:\projects\nuget-build-packaging\src\Build\NuGet.Build.Packaging.Tests\bin\Release\Scenarios\given_a_library_with_private_assets_reference\bin\a\a.xml, C:\projects\nuget-build-packaging\src\Build\NuGet.Build.Packaging.Tests\bin\Release\Scenarios\given_a_library_with_private_assets_reference\bin\a\a.pdb, Newtonsoft.Json, xunit, ...]
2171               Stack Trace:
2172                 src\Build\NuGet.Build.Packaging.Tests\given_a_library_with_private_assets_reference.cs(60,0): at NuGet.Build.Packaging.given_a_library_with_private_assets_reference.when_getting_package_contents_then_contains_private_lib_assets_as_primary_output_and_also_package_reference()
2173               Output:
2174                 The "SkipNonexistentTargets" parameter is not supported by the "MsBuild" task. Verify the parameter exists on the task, and it is a settable public instance property.
2175                 The "MsBuild" task could not be initialized with its input parameters. 
2176             NuGet.Build.Packaging.given_a_library_with_private_assets_reference.when_getting_package_contents_then_contains_private_assets_as_primary_output [FAIL]
2177               Assert.Contains() Failure
2178               Not found: (filter expression)
2179               In value:  TaskItem[] [C:\projects\nuget-build-packaging\src\Build\NuGet.Build.Packaging.Tests\bin\Release\Scenarios\given_a_library_with_private_assets_reference\bin\a\a.dll, C:\projects\nuget-build-packaging\src\Build\NuGet.Build.Packaging.Tests\bin\Release\Scenarios\given_a_library_with_private_assets_reference\bin\a\a.xml, C:\projects\nuget-build-packaging\src\Build\NuGet.Build.Packaging.Tests\bin\Release\Scenarios\given_a_library_with_private_assets_reference\bin\a\a.pdb, Newtonsoft.Json, xunit, ...]
2180               Stack Trace:
2181                 src\Build\NuGet.Build.Packaging.Tests\given_a_library_with_private_assets_reference.cs(38,0): at NuGet.Build.Packaging.given_a_library_with_private_assets_reference.when_getting_package_contents_then_contains_private_assets_as_primary_output()
2182               Output:
2183                 The "SkipNonexistentTargets" parameter is not supported by the "MsBuild" task. Verify the parameter exists on the task, and it is a settable public instance property.
2184                 The "MsBuild" task could not be initialized with its input parameters. 
2185           Finished:    NuGet.Build.Packaging.Tests
2186         === TEST EXECUTION SUMMARY ===
2187            NuGet.Build.Packaging.Tests  Total: 169, Errors: 0, Failed: 2, Skipped: 2, Time: 76.028s
2188

C:\projects\nuget-build-packaging\build.proj(90,5): error MSB3073: The command ""C:\Users\appveyor\.nuget\packages\xunit.runner.console\2.3.1\build\..\tools\net452\xunit.console.exe" C:\projects\nuget-build-packaging\src\Build\NuGet.Build.Packaging.Tests\bin\Release\NuGet.Build.Packaging.Tests.dll  -html C:\projects\nuget-build-packaging\out\test.html -xml C:\projects\nuget-build-packaging\out\test.xml -parallel all -noshadow" exited with code 1.

@kzu
Copy link
Contributor

kzu commented Aug 12, 2018

The failure are two failed unit tests. I'll take a look next week.

@kzu kzu closed this Aug 25, 2018
@kzu kzu reopened this Aug 25, 2018
@kzu kzu merged commit 86f6289 into NuGet:dev Aug 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants