Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpc.exe: exception occured while trying to generate #386

Closed
superduperbob opened this issue Feb 8, 2019 · 21 comments
Closed

mpc.exe: exception occured while trying to generate #386

superduperbob opened this issue Feb 8, 2019 · 21 comments

Comments

@superduperbob
Copy link

Hi there,

I'm currently working on a Unity project that is not PC exclusive and the other platforms require IL2CPP to build. After looking at the documentation it seems like I should use mpc to generate the code needed. Unfortunately I cannot seem to get mpc to generate anything as it keeps failing after running the command:

"C:\Users\me\Desktop\MessagePackUniversalCodeGenerator\win-x64\mpc.exe" -i "Assembly-CSharp.csproj" -o "MessagePackGenerated.cs"

When running this, I get the follow error:

C:\dev\test\Project\test2>"C:\Users\me\Desktop\MessagePackUniversalCodeGenerator\win-x64\mpc.exe" -i "Assembly-CSharp.csproj" -o "MessagePackGenerated.cs" Project Compilation Start:Assembly-CSharp.csproj exception occured(fname=dotnet, args=msbuild "C:\dev\test\Project\test2\Assembly-CSharp.csproj" /t:ResolveAssemblyReferencesDesignTime;ResolveProjectReferencesDesignTime;ResolveComReferencesDesignTime;Compile /p:IntermediateOutputPath="C:\dev\test\Project\test2\__buildtemp" /p:ProviderCommandLineArgs="true" /p:GenerateResourceMSBuildArchitecture="CurrentArchitecture" /p:DesignTimeBuild="true" /p:BuildProjectReferences="false" /p:SkipCompilerExecution="true" /p:DisableRarCache="true" /p:AutoGenerateBindingRedirects="false" /p:CopyBuildOutputToOutputDirectory="false" /p:CopyOutputSymbolsToOutputDirectory="false" /p:SkipCopyBuildProduct="true" /p:AddModules="false" /p:UseCommonOutputDirectory="true" /p:GeneratePackageOnBuild="false" /p:RunPostBuildEvent="false" /p:SolutionDir="C:\dev\test\Project\test2\Assembly-CSharp.csproj" /bl:"C:\dev\test\Project\test2\__buildtemp\build.binlog" /v:n):System.ComponentModel.Win32Exception (2): The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at MessagePack.CodeGenerator.ProcessUtil.ExecuteProcessAsync(String fileName, String args, Stream stdout, Stream stderr, TextReader stdin, CancellationToken ct) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\ProcessUtil.cs:line 29 at MessagePack.CodeGenerator.RoslynExtensions.TryExecute(String csprojPath, String tempPath, Boolean useDotNet) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 67 execute dotnet msbuildfailed, retry withmsbuild exception occured(fname=msbuild, args="C:\dev\test\Project\test2\Assembly-CSharp.csproj" /t:ResolveAssemblyReferencesDesignTime;ResolveProjectReferencesDesignTime;ResolveComReferencesDesignTime;Compile /p:IntermediateOutputPath="C:\dev\test\Project\test2\__buildtemp" /p:ProviderCommandLineArgs="true" /p:GenerateResourceMSBuildArchitecture="CurrentArchitecture" /p:DesignTimeBuild="true" /p:BuildProjectReferences="false" /p:SkipCompilerExecution="true" /p:DisableRarCache="true" /p:AutoGenerateBindingRedirects="false" /p:CopyBuildOutputToOutputDirectory="false" /p:CopyOutputSymbolsToOutputDirectory="false" /p:SkipCopyBuildProduct="true" /p:AddModules="false" /p:UseCommonOutputDirectory="true" /p:GeneratePackageOnBuild="false" /p:RunPostBuildEvent="false" /p:SolutionDir="C:\dev\test\Project\test2\Assembly-CSharp.csproj" /bl:"C:\dev\test\Project\test2\__buildtemp\build.binlog" /v:n):System.ComponentModel.Win32Exception (2): The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at MessagePack.CodeGenerator.ProcessUtil.ExecuteProcessAsync(String fileName, String args, Stream stdout, Stream stderr, TextReader stdin, CancellationToken ct) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\ProcessUtil.cs:line 29 at MessagePack.CodeGenerator.RoslynExtensions.TryExecute(String csprojPath, String tempPath, Boolean useDotNet) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 67 Unhandled Error:System.Exception: failed to build project at MessagePack.CodeGenerator.RoslynExtensions.GetAnalyzerResults(AnalyzerManager analyzerManager, String csprojPath, String[] preprocessorSymbols) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 101 at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspaceWithPreventBuildEventAsync(AnalyzerManager manager) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 148 at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject(String csprojPath, String[] preprocessorSymbols) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 126 at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable1 conditinalSymbols, Boolean disallowInternal, Boolean isForceUseMap) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\CodeAnalysis\TypeCollector.cs:line 212 at MessagePack.CodeGenerator.Program.Main(String[] args) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Program.cs:line 90

Anyone else had this before? I've tried different variations of this command and I just cannot get it to run.

Thanks for looking,
Matt

@simonjeesam
Copy link

I think you need to point MPC to .csproj, not Assembly-CSharp.csproj. At least that was the case for me on the old version of MPC before it became "MessagePackUniversalCodeGenerator".

@superduperbob
Copy link
Author

Hi Simon, thanks for the suggestion but unfortunately it doesn't seem to matter whether I point it to Assembly-CSharp.csproj or the project named .csproj (eg. MyProject.csproj), I still get the same the same error.

@neuecc
Copy link
Member

neuecc commented Feb 14, 2019

related to #355 ?

@jkampitakis
Copy link

jkampitakis commented Feb 18, 2019

we use the latest master branch and have an exception too

john-kampitakis:MessagePack-CSharp john$ dotnet build src/MessagePack -f netstandard1.6

Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 35.03 ms for /Users/john/Documents/MessagePack-CSharp/src/MessagePack/MessagePack.csproj.
MessagePack -> /Users/john/Documents/MessagePack-CSharp/bin/MessagePack/Debug/netstandard1.6/MessagePack.dll

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:00.96

john-kampitakis:MessagePack-CSharp john$ dotnet run -p src/MessagePack.UniversalCodeGenerator -- -i /Users/john/Documents/llshooter/Assembly-CSharp.csproj -o Generated.cs

Using launch settings from src/MessagePack.UniversalCodeGenerator/Properties/launchSettings.json...
Project Compilation Start:/Users/john/Documents/llshooter/Assembly-CSharp.csproj
Unhandled Error:System.AggregateException: One or more errors occurred. (Mismatched target events) ---> System.InvalidOperationException: Mismatched target events
at Buildalyzer.Logging.EventProcessor.TargetFinished(Object sender, TargetFinishedEventArgs e)
at Microsoft.Build.Logging.StructuredLogger.EventArgsDispatcher.Dispatch(BuildEventArgs buildEvent) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsDispatcher.cs:line 106
at Microsoft.Build.Logging.StructuredLogger.BinLogReader.<>c__DisplayClass7_0.b__0() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 62
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.Build.Logging.StructuredLogger.BinLogReader.Replay(Stream stream) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 96
at Microsoft.Build.Logging.StructuredLogger.BinLogReader.Replay(String sourceFilePath) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 37
at Buildalyzer.AnalyzerManager.Analyze(String binLogPath, IEnumerable1 buildLoggers) at MessagePack.CodeGenerator.RoslynExtensions.GetAnalyzerResults(AnalyzerManager analyzerManager, String csprojPath, String[] preprocessorSymbols) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 108 at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspaceWithPreventBuildEventAsync(AnalyzerManager manager) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 149 at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject(String csprojPath, String[] preprocessorSymbols) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 127 at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable1 conditinalSymbols, Boolean disallowInternal, Boolean isForceUseMap) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs:line 244
at MessagePack.CodeGenerator.Program.Main(String[] args) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Program.cs:line 88
---> (Inner Exception #0) System.InvalidOperationException: Mismatched target events
at Buildalyzer.Logging.EventProcessor.TargetFinished(Object sender, TargetFinishedEventArgs e)
at Microsoft.Build.Logging.StructuredLogger.EventArgsDispatcher.Dispatch(BuildEventArgs buildEvent) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsDispatcher.cs:line 106
at Microsoft.Build.Logging.StructuredLogger.BinLogReader.<>c__DisplayClass7_0.b__0() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 62
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)

@neuecc
Copy link
Member

neuecc commented Feb 19, 2019

Ah, I've encounted same problem,
it occured from analyzerManager.Analyze(Path.Combine(tempPath, "build.binlog").

@itn3000 Could you know any info?

@itn3000
Copy link
Contributor

itn3000 commented Feb 19, 2019

I think @superduperbob case and @jkampitakis case are different.

but I think It may be triggered by analyzing project using il2cpp.

I will investigate it deeper.
related buildalyzer source is https://github.com/daveaglick/Buildalyzer/blob/f9bc531172b1bb9143efaeb9709f0b8130faf88f/src/Buildalyzer/Logging/EventProcessor.cs

@itn3000
Copy link
Contributor

itn3000 commented Feb 25, 2019

I made the branch for second case.
It's still WIP(getting rid of debug code,cleanup,testing on unity's project is needed) but almost works correctly.

first case is because both dotnet(from dotnet-sdk) and msbuild(from mono or developer terminal for VS2017) commands are not found on PATH environment variable.
So workaround for this problem is install dotnet-sdk(for windows) or mono(for mac).

Unity's msbuild is deployed to difficult place for auto detecting,
so for resolve the problem without workaround, pragmatic solution for "how to detect and execute msbuild command" must be found.

neuecc added a commit that referenced this issue Feb 26, 2019
replacing Buildalyzer to MSBuild.StructuredLogger for Unity project(#386)
@jkampitakis
Copy link

We have some "progress" in this.

Using the latest mpc build.

john-kampitakis:osx-x64 john$ ./mpc -- -i /Users/john/Documents/llshooter/Assembly-CSharp.csproj -o Generated.cs
Project Compilation Start:/Users/john/Documents/llshooter/Assembly-CSharp.csproj
Fail in batch running on MessagepackCompiler.RunAsync
System.IO.FileNotFoundException: Could not find file '/Users/john/Documents/llshooter/Assets\Appodeal\Api\Appodeal.cs'.
File name: '/Users/john/Documents/llshooter/Assets\Appodeal\Api\Appodeal.cs'
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.File.AsyncStreamReader(String path, Encoding encoding)
at System.IO.File.InternalReadAllTextAsync(String path, Encoding encoding, CancellationToken cancellationToken)
at MessagePackCompiler.MessagePackCompilation.CreateFromProjectAsync(String[] csprojs, String[] preprocessorSymbols, CancellationToken cancellationToken) in C:\Git\MessagePack-CSharp\src\MessagePackCompiler\MessagePackCompilation.cs:line 46
at MessagePackCompiler.MessagepackCompiler.RunAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDiretiveOutputSymbols) in C:\Git\MessagePack-CSharp\src\MessagePackCompiler\Program.cs:line 44
at MicroBatchFramework.BatchEngine.RunCore(BatchContext ctx, Type type, MethodInfo methodInfo, String[] args, Int32 argsOffset)

@itn3000
Copy link
Contributor

itn3000 commented Mar 1, 2019

It might be caused by mixed file path with \ and /.
It should be normalized by mpc.

@jkampitakis
Copy link

jkampitakis commented Mar 1, 2019

Inside my Assembly-CSharp.csproj I see that there is the following line "Compile Include=Assets\Appodeal\Api\Appodeal.cs />"

This path seems alright to me. Does mpc reads it from somewhere else maybe?

Thanks.

@SuperKLA
Copy link

Is there any new progress on this issue? I step into the same error message and I also tried to fix it, but without any success. Is there way to create the generated file by hand?

itn3000 added a commit to itn3000/MessagePack-CSharp that referenced this issue Apr 1, 2019
itn3000 added a commit to itn3000/MessagePack-CSharp that referenced this issue Apr 1, 2019
@jkampitakis
Copy link

jkampitakis commented Apr 11, 2019

Using the latest master branch we still have errors:

dotnet run -p src/MessagePack.UniversalCodeGenerator -- -i /Users/john/Documents/llshooter/Assembly-CSharp.csproj -o Generated.cs

Produces the following error:

File name: '/Users/john/Documents/llshooter/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at Roslyn.Utilities.FileUtilities.OpenFileStream(String path) in /_/src/Compilers/Core/Portable/FileSystem/FileUtilities.cs:line 402 at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation) in /_/src/Compilers/Core/Portable/MetadataReference/MetadataReference.cs:line 232 at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspaceFromBuild(Build build, String[] preprocessorSymbols) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 224 at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject(String csprojPath, String[] preprocessorSymbols) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 255 at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable1 conditinalSymbols, Boolean disallowInternal, Boolean isForceUseMap) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs:line 244
at MessagePack.CodeGenerator.Program.Main(String[] args) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Program.cs:line 88

@jkampitakis
Copy link

jkampitakis commented Apr 16, 2019

Hello,
we are using the branch "fix-path-normalization"

dotnet run -p src/MessagePack.UniversalCodeGenerator -i /Users/john/Documents/llshooter/Assembly-CSharp.csproj -o Generated.cs

and the result is:

Using launch settings from src/MessagePack.UniversalCodeGenerator/Properties/launchSettings.json...
Project Compilation Start:/Users/john/Documents/llshooter/Assembly-CSharp.csproj
Unhandled Error:System.InvalidOperationException: failed to get metadata of MessagePack.MessagePackObjectAttribute
at MessagePack.CodeGenerator.ReferenceSymbols..ctor(Compilation compilation) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs:line 37
at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable`1 conditinalSymbols, Boolean disallowInternal, Boolean isForceUseMap) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs:line 245
at MessagePack.CodeGenerator.Program.Main(String[] args) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Program.cs:line 88

If we use the branch "mpc-normalize-path-separator":

dotnet run -p src/MessagePack.UniversalCodeGenerator -i /Users/john/Documents/llshooter/Assembly-CSharp.csproj -o Generated.cs

Project Compilation Start:/Users/john/Documents/llshooter/Assembly-CSharp.csproj
Unhandled Error:System.IO.FileNotFoundException: Could not find file '/Users/john/Documents/llshooter/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'.
File name: '/Users/john/Documents/llshooter/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at Roslyn.Utilities.FileUtilities.OpenFileStream(String path) in /_/src/Compilers/Core/Portable/FileSystem/FileUtilities.cs:line 402 at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation) in /_/src/Compilers/Core/Portable/MetadataReference/MetadataReference.cs:line 232 at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspaceFromBuild(Build build, String[] preprocessorSymbols) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 225 at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject(String csprojPath, String[] preprocessorSymbols) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 256 at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable1 conditinalSymbols, Boolean disallowInternal, Boolean isForceUseMap) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs:line 244
at MessagePack.CodeGenerator.Program.Main(String[] args) in /Users/john/Documents/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Program.cs:line 88

@mmankt
Copy link

mmankt commented Apr 25, 2019

I'm running into the same error. I'm trying to workaround this by putting all messagepackobjects from my project to a clean project and it generates all the files properly.

@mmatvein
Copy link

One thing I've noticed is that you need to have the MessagePack files under the same assembly as the classes you want to generate code from. I tried having MessagePack in the Plugins folder or under its own assembly, but only got an empty file.

@LloydVincent
Copy link

There is definitely an issue with assemblies.

My project uses assemblies so I want to generate from a different .csproj than Assembly-CSharp.proj, and I'd also like to include MessagePack in a different assembly than the target.

However, when message pack is executed on the command line it always looks in Assembly-CSharp.proj for path information. This information is never correct because the folder where I want to keep message pack is always in a different assembly.

My workaround:

  • Usually my project doesn't even update Assembly-CSharp.proj because everything is in an assembly, but I temporarily removed my asmdefs one time to get MessagePack references to appear in Assembly-CSharp.proj
  • I then restored my asmdefs and put everything where I wanted it (MessagePack in the plugins folder with its own asmdef).
  • I manually did a find/replace in Assembly-CSharp.proj to point to correct paths for MessagePack
  • Command line now works properly

Here is the error that occurs when the path in Assembly-CSharp.proj is not correct.

C:/Users/LV3/Documents/LV/Unity/Assets/../../Tools/MessagePackUniversalCodeGenerator/win-x64/mpc.exe -i C:/Users/LV3/Documents/LV/Unity/Assets/../LV.Puzzle.csproj -o C:/Users/LV3/Documents/LV/Unity/Assets/Scripts/Generated/MessagePack.Generated.cs Project Compilation Start:C:/Users/LV3/Documents/LV/Unity/Assets/../LV.Puzzle.csproj Unhandled Error:System.AggregateException: One or more errors occurred. (Mismatched target events) ---> System.InvalidOperationException: Mismatched target events at Buildalyzer.Logging.EventProcessor.TargetFinished(Object sender, TargetFinishedEventArgs e) at Microsoft.Build.Logging.StructuredLogger.EventArgsDispatcher.Dispatch(BuildEventArgs buildEvent) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsDispatcher.cs:line 106 at Microsoft.Build.Logging.StructuredLogger.BinLogReader.<>c__DisplayClass7_0.<Replay>b__0() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 62 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Microsoft.Build.Logging.StructuredLogger.BinLogReader.Replay(Stream stream) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 96 at Microsoft.Build.Logging.StructuredLogger.BinLogReader.Replay(String sourceFilePath) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 37 at Buildalyzer.AnalyzerManager.Analyze(String binLogPath, IEnumerable1 buildLoggers)
at MessagePack.CodeGenerator.RoslynExtensions.GetAnalyzerResults(AnalyzerManager analyzerManager, String csprojPath, String[] preprocessorSymbols) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 107
at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspaceWithPreventBuildEventAsync(AnalyzerManager manager) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 148
at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject(String csprojPath, String[] preprocessorSymbols) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 126
at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable1 conditinalSymbols, Boolean disallowInternal, Boolean isForceUseMap) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\CodeAnalysis\TypeCollector.cs:line 212 at MessagePack.CodeGenerator.Program.Main(String[] args) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Program.cs:line 90 ---> (Inner Exception #0) System.InvalidOperationException: Mismatched target events at Buildalyzer.Logging.EventProcessor.TargetFinished(Object sender, TargetFinishedEventArgs e) at Microsoft.Build.Logging.StructuredLogger.EventArgsDispatcher.Dispatch(BuildEventArgs buildEvent) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsDispatcher.cs:line 106 at Microsoft.Build.Logging.StructuredLogger.BinLogReader.<>c__DisplayClass7_0.<Replay>b__0() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 62 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

@LloydVincent
Copy link

Oops, was wrong about one thing. It seems the MessagePack files DO need to be a part of the same assembly as the target csproj file.

@LloydVincent
Copy link

LloydVincent commented Sep 5, 2019

I also get the above error if I try to change or remove the namespace of a MessagePackObject class when the MessagePack.Generated.cs file already exists. Deleting MessagePack.Generated.cs allows the file to be re-generated without errors.

Edit at least, I thought that was what was happening. But now it seems the command simply fails/succeeds randomly. Even after an error on the console, re-running the same exact command was successful? Now I'm really confused...

Edit 2 and now everything works fine from the command line, but always fails when I run it from a Process in the editor. WTAF? lol (again without any changes to my code or the command)

@kt81
Copy link

kt81 commented Oct 3, 2019

I occurred the problem like @LloydVincent wrote.
It succeeds/fails randomly.

This behaviour seems begun to occur after I added an asmdef file to the project.
However deleting the asmdef file does not solve it in my case.

@JakubHolovsky
Copy link
Contributor

JakubHolovsky commented Jan 13, 2020

Also got this error - today tried upgrading from 1.7.3.7 to latest

1> Fail in batch running on MessagepackCompiler.RunAsync
1> System.IO.FileNotFoundException: Could not find file 'C:\Users\jakub\AppData\Local\Temp.net\mpc\o03cedsz.3ig\System.dll'.
1> File name: 'C:\Users\jakub\AppData\Local\Temp.net\mpc\o03cedsz.3ig\System.dll'
1> at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
1> at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
1> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
1> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
1> at System.IO.File.OpenRead(String path)
1> at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
1> at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
1> at MessagePackCompiler.MessagePackCompilation.CreateFromProjectAsync(String[] csprojs, String[] preprocessorSymbols, CancellationToken cancellationToken)
1> at MessagePackCompiler.CodeGenerator.GenerateFileAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols)
1> at MessagePack.Generator.MessagepackCompiler.RunAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols)
1> at MicroBatchFramework.BatchEngine.RunCore(BatchContext ctx, Type type, MethodInfo methodInfo, String[] args, Int32 argsOffset)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(5185,5): error MSB3073: The command "if Debug == Debug E:\Dev\foobar\Utils\mpc\win\mpc.exe -i "E:\Dev\foobar\foobar.Api.Entities\foobar.Api.Entities.csproj" -o "E:\Dev\foobar\foobar.Core.NetStandard\MessagePackGenerated.cs"" exited with code 1.

@neuecc
Copy link
Member

neuecc commented Jan 14, 2020

This issue mainly talked about preview generator for 1.x, that is outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests