AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 59 forks source link

Referencing the code generator attribute DLL via output path breaks the compile step #17

Closed weltkante closed 5 years ago

weltkante commented 7 years ago

When I reference the code generator by selecting the DLL from its output path then the project can no longer be built. (using a project-to-project reference works but requires the generator project to be loaded into the same solution)

1>------ Build started: Project: Test, Configuration: Debug Any CPU ------
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018: The "GenerateCodeFromAttributes" task failed unexpectedly.
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018: System.Reflection.ReflectionTypeLoadException: Mindestens ein Typ in der Assembly kann nicht geladen werden. Rufen Sie die LoaderExceptions-Eigenschaft ab, wenn Sie weitere Informationen benötigen.
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at System.Reflection.RuntimeAssembly.get_DefinedTypes()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at System.Composition.Hosting.ContainerConfiguration.<WithAssemblies>b__0(Assembly a)
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(IEnumerable`1 assemblies)
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.get_DefaultHost()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at Microsoft.CodeAnalysis.AdhocWorkspace..ctor()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at CodeGeneration.Roslyn.Tasks.Helper.CreateProject()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at CodeGeneration.Roslyn.Tasks.Helper.<<Execute>b__37_1>d.MoveNext()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at CodeGeneration.Roslyn.Tasks.Helper.Execute()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at CodeGeneration.Roslyn.Tasks.Helper.Execute()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at CodeGeneration.Roslyn.Tasks.GenerateCodeFromAttributes.Execute()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Users\...\.nuget\packages\codegeneration.roslyn.buildtime\0.2.10\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Using VS 2017 RTM and nuget package 0.2.10

Note: I've made sure to set build dependencies manually so the problem is not that VS tries to compile both at the same time and the DLL is temporarily gone. [edit] also the problem happens if the project is not in the solution at all.

amis92 commented 5 years ago

@weltkante Since this is a very old issue and the project was drastically refactored, I'll close this for now. If you still experience the issue with the current version, please open new one.