Skip to content

Conversation

@jonathanpeppers
Copy link
Member

BCL Test phases are failing with:

remap-assembly-ref.cs(3,12): error CS0234: The type or namespace name 'Cecil' does not exist in the namespace 'Mono' (are you missing an assembly reference?)

The problem being Mono.Cecil.dll does not actually exist:

warning MSB3245: Could not resolve this reference. Could not locate the assembly "Mono.Cecil". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

This appears to have started failing since 49e570d.

19c3b73 fixed the issue with needing /restore, but this is the next
issue...

Reviewing a build log from before 49e570d, it only worked because
the build was pulling Mono.Cecil.dll from Mono's GAC:

Task ResolveAssemblyReference
    Reference found at search path location "{GAC}".
    ...
    Considered "/Users/runner/work/1/s/external/mono/sdks/out/android-bcl/monodroid_tools/Mono.Cecil.dll", but it didn't exist.
    ...
OutputItems
    ReferencePath
        /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/gac/Mono.Cecil/0.11.1.0__0738eb9f132ed756/Mono.Cecil.dll

Switching to Microsoft.NET.Sdk prevented the probing of the GAC,
because $(AssemblySearchPaths) does not contain {GAC} in the
dotnet/sdk:

https://github.com/dotnet/sdk/blob/ee455863aa6ddf13108bb54b37a5a47fb12fe39e/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props#L90-L91

To fix the problem, I think we should just use a <PackageReference/>
for Mono.Cecil in this tool.

I also updated Step_DetermineAzurePipelinesTestJobs, so changes to
build-tools will run all tests.

BCL Test phases are failing with:

    remap-assembly-ref.cs(3,12): error CS0234: The type or namespace name 'Cecil' does not exist in the namespace 'Mono' (are you missing an assembly reference?)

The problem being `Mono.Cecil.dll` does not actually exist:

    warning MSB3245: Could not resolve this reference. Could not locate the assembly "Mono.Cecil". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

This appears to have started failing since 49e570d.

19c3b73 fixed the issue with needing `/restore`, but this is the next
issue...

Reviewing a build log from before 49e570d, it *only* worked because
the build was pulling `Mono.Cecil.dll` from Mono's GAC:

    Task ResolveAssemblyReference
        Reference found at search path location "{GAC}".
        ...
        Considered "/Users/runner/work/1/s/external/mono/sdks/out/android-bcl/monodroid_tools/Mono.Cecil.dll", but it didn't exist.
        ...
    OutputItems
        ReferencePath
            /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/gac/Mono.Cecil/0.11.1.0__0738eb9f132ed756/Mono.Cecil.dll

Switching to `Microsoft.NET.Sdk` prevented the probing of the GAC,
because `$(AssemblySearchPaths)` does not contain `{GAC}` in the
dotnet/sdk:

https://github.com/dotnet/sdk/blob/ee455863aa6ddf13108bb54b37a5a47fb12fe39e/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props#L90-L91

To fix the problem, I think we should just use a `<PackageReference/>`
for Mono.Cecil in this tool.

I also updated `Step_DetermineAzurePipelinesTestJobs`, so changes to
`build-tools` will run all tests.
Copy link
Member

@radekdoulik radekdoulik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is failing now when running the tool.

2021-01-20T03:55:48.5658121Z       * Remapping Cecil references for bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\illinkanalyzer.exe
2021-01-20T03:55:48.5659593Z   Running: bin\BuildRelease\remap-assembly-ref.exe "external\mono\sdks\out\android-bcl\monodroid_tools\illinkanalyzer.exe" "bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\illinkanalyzer.exe" "Mono.Cecil" "bin\BuildRelease\Xamarin.Android.Cecil.dll"
2021-01-20T03:55:48.8772802Z   stderr | 
2021-01-20T03:55:48.8907533Z   stderr | Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
2021-01-20T03:55:48.8909284Z   stderr |    at Remap.Main(String[] args)
2021-01-20T03:55:52.0890871Z ##[error]EXEC(0,0): Error : Failed to remap cecil reference for C:\a\1\s\bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\illinkanalyzer.exe
2021-01-20T03:55:52.0893339Z ##[debug]Processed: ##vso[task.logissue type=Error;sourcepath=EXEC;linenumber=0;columnnumber=0;code=;]Failed to remap cecil reference for C:\a\1\s\bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\illinkanalyzer.exe
2021-01-20T03:55:52.0895123Z EXEC : error : Failed to remap cecil reference for C:\a\1\s\bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\illinkanalyzer.exe [C:\a\1\s\Xamarin.Android.sln]
2021-01-20T03:55:52.0909466Z   
2021-01-20T03:55:52.0911529Z   Step Xamarin.Android.Prepare.Step_InstallMonoRuntimes failed
2021-01-20T03:55:52.0912591Z   System.InvalidOperationException: Step Xamarin.Android.Prepare.Step_InstallMonoRuntimes failed
2021-01-20T03:55:52.0914222Z      at Xamarin.Android.Prepare.Scenario.<Run>d__26.MoveNext() in C:\a\1\s\build-tools\xaprepare\xaprepare\Application\Scenario.cs:line 50
2021-01-20T03:55:52.0915689Z   --- End of stack trace from previous location where exception was thrown ---
2021-01-20T03:55:52.0916634Z      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-01-20T03:55:52.0917602Z      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-01-20T03:55:52.0918821Z      at Xamarin.Android.Prepare.Context.<Execute>d__202.MoveNext() in C:\a\1\s\build-tools\xaprepare\xaprepare\Application\Context.cs:line 816
2021-01-20T03:55:52.0919984Z   --- End of stack trace from previous location where exception was thrown ---
2021-01-20T03:55:52.0920894Z      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-01-20T03:55:52.0921857Z      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-01-20T03:55:52.0922979Z      at Xamarin.Android.Prepare.App.<Run>d__3.MoveNext() in C:\a\1\s\build-tools\xaprepare\xaprepare\Main.cs:line 164
2021-01-20T03:55:52.0923855Z   
2021-01-20T03:55:52.6037791Z ##[error]build-tools\scripts\PrepareWindows.targets(24,5): Error MSB3073: The command "C:\a\1\s\build-tools\scripts\..\xaprepare\xaprepare\bin\Release\xaprepare.exe --no-emoji --run-mode=CI -v:d -a" exited with code 1.

I will try to reproduce it on my machine.

@radekdoulik
Copy link
Member

Looks like we are overwritting bin/Build$(Configuration)/Mono.Cecil.dll with older version during build.

@jonathanpeppers jonathanpeppers marked this pull request as ready for review January 20, 2021 17:15
<Reference Include="Mono.Cecil">
<HintPath>$(XamarinAndroidSourcePath)external\mono\sdks\out\android-bcl\monodroid_tools\Mono.Cecil.dll</HintPath>
</Reference>
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the version a property in Configuration.props? I'm working on a PR which will add a tool that also uses Cecil, it would be good to share the package version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense, added. 👍

@jonpryor jonpryor merged commit 549f2ce into dotnet:master Jan 21, 2021
@jonathanpeppers jonathanpeppers deleted the remap-assembly-ref-mono.cecil branch January 21, 2021 02:56
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
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.

4 participants