Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

CoreRT and MrAdvice compiler chain incompatibility #6138

Closed
hhblaze opened this issue Jul 25, 2018 · 8 comments
Closed

CoreRT and MrAdvice compiler chain incompatibility #6138

hhblaze opened this issue Jul 25, 2018 · 8 comments

Comments

@hhblaze
Copy link

hhblaze commented Jul 25, 2018

MrAdvice is a free aspect weaver for .NET family (alternative to Postsharp)
has such nuget .target file definition

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <MrAdvicePath Condition="$(MrAdvicePath) == '' Or $(MrAdvicePath) == '*Undefined*'">$(MSBuildThisFileDirectory)..\build\MrAdvice.Weaver.exe</MrAdvicePath>
  </PropertyGroup>

  <UsingTask TaskName="MrAdviceTask" AssemblyFile="$(MrAdvicePath)" />
  <Target Name="MrAdviceWeaver" AfterTargets="CoreCompile" BeforeTargets="CopyFilesToOutputDirectory" Outputs="@(IntermediateAssembly[0]).♥MrAdvice">
    <MrAdviceTask AssemblyPath="@(IntermediateAssembly)" ReferencePath="@(ReferencePath)" ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
                  AssemblyOriginatorKeyFile="$(AssemblyOriginatorKeyFile)" SignAssembly="$(SignAssembly)" />
  </Target>
</Project>

it runs the MrAdvice.Weaver.exe, after compilation to IL, to transform the assembly.
Only after that it had to be picked up by CoreRT that is not happening due to the CoreRT compile chain logic.

If it is just added into the project as NuGet package the CoreRT toolchain fails with:

D:\Temp\hw\HelloWorld1>dotnet publish -r win-x64 -c release
Microsoft (R) Build Engine version 15.7.179.6572 для .NET Core
(Microsoft Corporation). Все права защищены.

Restore is completed 52,04 ms for D:\Temp\hw\HelloWorld1\HelloWorld1.csproj. 
C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error MSB4062: 
Can't load task "MrAdviceTask" from assembly "C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build
\..\build\MrAdvice.Weaver.exe". 
Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, 
Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a'. 
Can't find file. Check declaration <UsingTask>, 
accessibility of the assembly with all its dependencies and existence of the common class,
 implementing Microsoft.Build.Framework.ITask. [D:\Temp\hw\HelloWorld1\HelloWorld1.csproj]

Removing MrAdvice from the NuGet references leads to a successful compilation.

Here is also a MrAdvice linked issue

Question: what should be changed in declarations of MrAdvice (or extra configurations of CoreRT should be done) to make these two projects compatible?

@jkotas
Copy link
Member

jkotas commented Jul 25, 2018

@sbomer This is the problem with colliding post-build steps that we have seen in other places. I am pretty sure that ILLinker is going to hit the same problem with MrAdvice as well. Have we done anything towards fixing it?

cc @jeffschwMSFT

@hhblaze
Copy link
Author

hhblaze commented Jun 7, 2019

Hi guys, any note about this issue?

@sbomer
Copy link
Member

sbomer commented Jun 7, 2019

@hhblaze, we unfortunately don't have a solution for the interaction between IL transformation tools. The issue is that we don't have a supported extension point: dotnet/sdk#2583.

However, the above error looks like something different to me - it's not finding a dependency of the MrAdvice assembly (it's looking for Microsoft.Build.Utilities). Have you been able to run MrAdvice on a .NET Core (not CoreRT) app? If not, this would suggest that the MrAdvice package needs to be updated to work on .NET Core.

@picrap
Copy link

picrap commented Jun 7, 2019

I think we'll make changes to MrAdvice weaver once everything is clear here.

@hhblaze
Copy link
Author

hhblaze commented Jun 8, 2019

@sbomer before publishing to CoreRT it is a valid .NET Core app that works together with MrAdvice

@sbomer
Copy link
Member

sbomer commented Jun 10, 2019

@hhblaze, I gave the sample above a try without CoreRT, and I hit a similar issue in MrAdvice. Could you try this again, with the same publish command as above, and let me know if you see the same? At the moment I believe this is due to MrAdvice not working when using the .NET Core version of msbuild.

@hhblaze
Copy link
Author

hhblaze commented Jun 11, 2019

@sbomer looks like you are right.
So, @picrap probably we should close this issue here and leave only this with the issue renaming?

@picrap
Copy link

picrap commented Jun 11, 2019

I'm not the boss here, do as you want 😉.

@hhblaze hhblaze closed this as completed Jun 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants