Capgemini / Cauldron

C# Toolkit
MIT License
77 stars 18 forks source link

[Cauldron.Interception.Fody] build error on Mac #69

Open jessejiang0214 opened 6 years ago

jessejiang0214 commented 6 years ago

I used VS for mac to build a custom interception project then I got this error Fody/Cauldron.Interception: Cauldron Interception v3.0.0.35 Fody/Cauldron.Interception: ----- Implementing decorator interceptors took 12.0541ms ----- Fody/Cauldron.Interception: Compiling custom interceptor: AddMethodsToClass.csx Fody/Cauldron.Interception:
Fody/Cauldron.Interception: Cannot open assembly '/packages/cauldron.interception.fody/3.0.35-beta/netclassicweaver/csccsc.exe': No such file or directory. Fody/Cauldron.Interception:
Fody/Cauldron.Interception: ----- Implementing custom interceptors interceptors took 965.3508ms ----- MSBUILD : error : Fody: An unhandled exception occurred: MSBUILD : error : Exception: MSBUILD : error : Failed to execute weaver packages/cauldron.interception.fody/3.0.35-beta/netclassicweaver/Cauldron.Interception.Fody.dll MSBUILD : error : Type: MSBUILD : error : System.Exception MSBUILD : error : StackTrace: MSBUILD : error : at InnerWeaver.ExecuteWeavers () [0x0007a] in C:\projects\fody\FodyIsolated\InnerWeaver.cs:214 MSBUILD : error : at InnerWeaver.Execute () [0x0009f] in C:\projects\fody\FodyIsolated\InnerWeaver.cs:109 MSBUILD : error : Source: MSBUILD : error : FodyIsolated MSBUILD : error : TargetSite: MSBUILD : error : Void ExecuteWeavers() MSBUILD : error : An error has occured while compiling '/test/Tests/AddMethodsToClass-3.0.0.35/74218D1A7DE4A5A65FB74A8519C66DD1.cs' MSBUILD : error : Type: MSBUILD : error : System.Exception MSBUILD : error : StackTrace: MSBUILD : error : at Cauldron.Interception.Fody.ModuleWeaver.CompileScript (System.String compiler, System.String path, System.Collections.Generic.IEnumerable1[T] references) [0x0014b] in <b5e227d79a1b4e418b622e943b76b951>:0 MSBUILD : error : at Cauldron.Interception.Fody.ModuleWeaver.LoadScript (System.String path) [0x00042] in <b5e227d79a1b4e418b622e943b76b951>:0 MSBUILD : error : at Cauldron.Interception.Fody.ModuleWeaver.<ExecuteInterceptionScripts>b__20_2 (System.String x) [0x00000] in <b5e227d79a1b4e418b622e943b76b951>:0 MSBUILD : error : at System.Linq.Enumerable+SelectEnumerableIterator2[TSource,TResult].MoveNext () [0x00036] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/Select.cs:131 MSBUILD : error : at System.Collections.Generic.List1[T].InsertRange (System.Int32 index, System.Collections.Generic.IEnumerable1[T] collection) [0x000ea] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs:744 MSBUILD : error : at System.Collections.Generic.List1[T].AddRange (System.Collections.Generic.IEnumerable1[T] collection) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs:255 MSBUILD : error : at Cauldron.Interception.Fody.ModuleWeaver.ExecuteInterceptionScripts (Cauldron.Interception.Cecilator.Builder builder) [0x0012a] in :0 MSBUILD : error : at Cauldron.Interception.Fody.ModuleWeaver.OnExecute () [0x0005f] in :0 MSBUILD : error : at Cauldron.Interception.Cecilator.WeaverBase.Execute () [0x0007d] in <9caaf1c82dd6419e9b178532dfa71948>:0 MSBUILD : error : at InnerWeaver.ExecuteWeavers () [0x0006b] in C:\projects\fody\FodyIsolated\InnerWeaver.cs:210 MSBUILD : error : Source: MSBUILD : error : Cauldron.Interception.Fody MSBUILD : error : TargetSite: MSBUILD : error : System.String CompileScript(System.String, System.String, System.Collections.Generic.IEnumerable`1[System.String]) MSBUILD : error : Fody: Finished Fody 4698ms. Done building target "FodyTarget" in project "Tests.csproj" -- FAILED.

I think something wrong with this line cscPath = Path.Combine(this.AddinDirectoryPath, "csc\csc.exe");

https://github.com/Capgemini/Cauldron/blob/master/Fody/Cauldron.Interception.Fody/ModuleWeaver_Scripting.cs

reflection-emit commented 6 years ago

Hi,

The scripting feature is actually a Windows only thing. But I think this is a good opportunity to make this also works on Mac. I need your help here... If you type in csc in the console what version of the compiler is executed?


Firma: Capgemini Deutschland GmbH Aufsichtsratsvorsitzender: Antonio Schnieder • Geschäftsführer: Dr. Michael Schulte (Sprecher) • Jost Förster • Dr. Peter Lempp • Dr. Volkmar Varnhagen

Amtsgericht Berlin-Charlottenburg, HRB 98814 This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

jessejiang0214 commented 6 years ago

I think you can use Roslyn.

reflection-emit commented 6 years ago

Yes that is a good idea, but it does not work. During build there is already a version of the roslyn library that is loaded. Referencing another version in the Fody extension causes a loading exception. So I have to actually reference exactly the same version. Thats means that if the roslyn version in VS is updated my Fody extension won’t work anymore. I already tried with CSScript which has 3 different options Mono, classic and Roslyn. The roslyn does not work because of the reason above. The mono version was not able to compile my lambda-heavy scripts. The classic one seems to be an old version of csc. I also tried dotnet script, but since it is using roslyn I ran into the same problem described above. Another option I haven’t looked into is dynamically loading the roslyn library.


Firma: Capgemini Deutschland GmbH Aufsichtsratsvorsitzender: Antonio Schnieder • Geschäftsführer: Dr. Michael Schulte (Sprecher) • Jost Förster • Dr. Peter Lempp • Dr. Volkmar Varnhagen

Amtsgericht Berlin-Charlottenburg, HRB 98814 This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

reflection-emit commented 5 years ago

I am switching the script engine to CSScript… http://www.csscript.net/ This should solve the problem. But it also means no C# 6 features.