I think new mpc generate empty GeneratedResolver always.
I got same result by sandbox/SharedData/SharedData.csproj in this repository, and own project csproj.
./osx-x64/mpc -i /Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj -o ~/Desktop/Test.cs
#pragma warning disable 618
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
namespace MessagePack.Resolvers
{
using System;
using MessagePack;
public class GeneratedResolver : global::MessagePack.IFormatterResolver
{
public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver();
GeneratedResolver()
{
}
public global::MessagePack.Formatters.IMessagePackFormatter<T> GetFormatter<T>()
{
return FormatterCache<T>.formatter;
}
static class FormatterCache<T>
{
public static readonly global::MessagePack.Formatters.IMessagePackFormatter<T> formatter;
static FormatterCache()
{
var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T));
if (f != null)
{
formatter = (global::MessagePack.Formatters.IMessagePackFormatter<T>)f;
}
}
}
}
internal static class GeneratedResolverGetFormatterHelper
{
static readonly global::System.Collections.Generic.Dictionary<Type, int> lookup;
static GeneratedResolverGetFormatterHelper()
{
lookup = new global::System.Collections.Generic.Dictionary<Type, int>(0)
{
};
}
internal static object GetFormatter(Type t)
{
int key;
if (!lookup.TryGetValue(t, out key)) return null;
switch (key)
{
default: return null;
}
}
}
}
#pragma warning restore 168
#pragma warning restore 414
#pragma warning restore 618
#pragma warning restore 612
I tested on ubuntu-18.04 and got same output.
I think this is the difference of windows and other platform.
Buildalzyer uses dotnet command in ProjectAnalyzer.Build(),
but linux(and mac)'s SDK does not resolve net461 framework, so internal build will be failed.
This can be avoided by
msbuild command with '/bl:[output file path]' optionAnalyzerManager.Analyze()AnalyzerResult.AddToWorkspace()I'm getting results identical to those above on a Windows Unity project.
mpc.exe -i ..\Src.csproj -o ..\Assets\Src\MessagePackGenerated.cs generates an empty GeneratedResolver.
Does anyone have a fix?
I'm trying to resolve the problem, and this is my progress.
Currently, I'm thinking about the following points
dotnet msbuild and msbuildI'm trying to resolve the problem, and this is my progress.
Currently, I'm thinking about the following points
how to determine the command line?
- should it be determined by Platform, commandline option
- or trying both
dotnet msbuildandmsbuildhow to resolve the path for msbuild or dotnet?
- currently, it is hard-coded
Hi, have you managed to solve this issue?
my fix is replacing from using Buildalyzer.ProjectAnalyzer.Build() to generate msbuild's binary log and Buildalyzer.AnalyzerManager.Analyze().
so mono-devel package is needed when generating from net46x project if linux or mac.
my fix is replacing from using
Buildalyzer.ProjectAnalyzer.Build()to generate msbuild's binary log andBuildalyzer.AnalyzerManager.Analyze().
so mono-devel package is needed when generating from net46x project if linux or mac.
Sorry, I have no idea what this means..
Do you have a working example?
Kind regards
I am having the following error
Unhandled Exception:
System.NotImplementedException: The method or operation is not implemented.
at System.IO.Pipes.AnonymousPipeServerStream..ctor (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability, System.Int32 bufferSize, System.IO.Pipes.PipeSecurity pipeSecurity) [0x00031] in <7505d9a21cfc4fc7b41cb4768918fdb4>:0
at System.IO.Pipes.AnonymousPipeServerStream..ctor (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability, System.Int32 bufferSize) [0x00000] in <7505d9a21cfc4fc7b41cb4768918fdb4>:0
at System.IO.Pipes.AnonymousPipeServerStream..ctor (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability) [0x00000] in <7505d9a21cfc4fc7b41cb4768918fdb4>:0
at (wrapper remoting-invoke-with-check) System.IO.Pipes.AnonymousPipeServerStream..ctor(System.IO.Pipes.PipeDirection,System.IO.HandleInheritability)
at MsBuildPipeLogger.AnonymousPipeLoggerServer..ctor (System.Threading.CancellationToken cancellationToken) [0x00000] in <56c3d20ea88740ccbb8467d8ac6e1ab2>:0
at Buildalyzer.ProjectAnalyzer.BuildTargets (Buildalyzer.Environment.BuildEnvironment buildEnvironment, System.String targetFramework, System.String[] targetsToBuild, Buildalyzer.AnalyzerResults results) [0x0001c] in <77d865e836a946fa9f4b5c781e80bf3a>:0
at Buildalyzer.ProjectAnalyzer.Build (System.String targetFramework, Buildalyzer.Environment.BuildEnvironment buildEnvironment) [0x00027] in <77d865e836a946fa9f4b5c781e80bf3a>:0
at Buildalyzer.ProjectAnalyzer.Build (System.String targetFramework, Buildalyzer.Environment.EnvironmentOptions environmentOptions) [0x0001d] in <77d865e836a946fa9f4b5c781e80bf3a>:0
at Buildalyzer.ProjectAnalyzer.Build (Buildalyzer.Environment.EnvironmentOptions environmentOptions) [0x00000] in <77d865e836a946fa9f4b5c781e80bf3a>:0
at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject (System.String csprojPath, System.Int32 verbosityLevel, System.Collections.Generic.Dictionary2[TKey,TValue] additionalProperties, System.Collections.Generic.IEnumerable1[T] conditionalSymbols) [0x004e7] in <9cb73f6c053a49038fbb2c51cc5ecabb>:0
at MessagePack.CodeGenerator.TypeCollector..ctor (System.String csProjPath, System.Int32 verbosityLevel, System.Collections.Generic.Dictionary2[TKey,TValue] additionalProperties, System.Collections.Generic.IEnumerable1[T] conditinalSymbols, System.Boolean disallowInternal, System.Boolean isForceUseMap) [0x006c5] in <9cb73f6c053a49038fbb2c51cc5ecabb>:0
at MessagePack.CodeGenerator.Program.Main (System.String[] args) [0x00086] in <9cb73f6c053a49038fbb2c51cc5ecabb>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotImplementedException: The method or operation is not implemented.
at System.IO.Pipes.AnonymousPipeServerStream..ctor (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability, System.Int32 bufferSize, System.IO.Pipes.PipeSecurity pipeSecurity) [0x00031] in <7505d9a21cfc4fc7b41cb4768918fdb4>:0
at System.IO.Pipes.AnonymousPipeServerStream..ctor (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability, System.Int32 bufferSize) [0x00000] in <7505d9a21cfc4fc7b41cb4768918fdb4>:0
at System.IO.Pipes.AnonymousPipeServerStream..ctor (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability) [0x00000] in <7505d9a21cfc4fc7b41cb4768918fdb4>:0
at (wrapper remoting-invoke-with-check) System.IO.Pipes.AnonymousPipeServerStream..ctor(System.IO.Pipes.PipeDirection,System.IO.HandleInheritability)
at MsBuildPipeLogger.AnonymousPipeLoggerServer..ctor (System.Threading.CancellationToken cancellationToken) [0x00000] in <56c3d20ea88740ccbb8467d8ac6e1ab2>:0
at Buildalyzer.ProjectAnalyzer.BuildTargets (Buildalyzer.Environment.BuildEnvironment buildEnvironment, System.String targetFramework, System.String[] targetsToBuild, Buildalyzer.AnalyzerResults results) [0x0001c] in <77d865e836a946fa9f4b5c781e80bf3a>:0
at Buildalyzer.ProjectAnalyzer.Build (System.String targetFramework, Buildalyzer.Environment.BuildEnvironment buildEnvironment) [0x00027] in <77d865e836a946fa9f4b5c781e80bf3a>:0
at Buildalyzer.ProjectAnalyzer.Build (System.String targetFramework, Buildalyzer.Environment.EnvironmentOptions environmentOptions) [0x0001d] in <77d865e836a946fa9f4b5c781e80bf3a>:0
at Buildalyzer.ProjectAnalyzer.Build (Buildalyzer.Environment.EnvironmentOptions environmentOptions) [0x00000] in <77d865e836a946fa9f4b5c781e80bf3a>:0
at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject (System.String csprojPath, System.Int32 verbosityLevel, System.Collections.Generic.Dictionary2[TKey,TValue] additionalProperties, System.Collections.Generic.IEnumerable1[T] conditionalSymbols) [0x004e7] in <9cb73f6c053a49038fbb2c51cc5ecabb>:0
at MessagePack.CodeGenerator.TypeCollector..ctor (System.String csProjPath, System.Int32 verbosityLevel, System.Collections.Generic.Dictionary2[TKey,TValue] additionalProperties, System.Collections.Generic.IEnumerable1[T] conditinalSymbols, System.Boolean disallowInternal, System.Boolean isForceUseMap) [0x006c5] in <9cb73f6c053a49038fbb2c51cc5ecabb>:0
at MessagePack.CodeGenerator.Program.Main (System.String[] args) [0x00086] in <9cb73f6c053a49038fbb2c51cc5ecabb>:0
_
I got the same problem here on MacOS
Unhandled Exception: System.AggregateException: One or more errors occurred. (One or more errors occurred. (No such file or directory)) (No such file or directory) ---> System.ComponentModel.Win32Exception: No such file or directory
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Buildalyzer.Environment.ProcessRunner.Start()
at Buildalyzer.Environment.DotnetPathResolver.GetInfo(String projectPath, String dotnetExePath)
at Buildalyzer.Environment.DotnetPathResolver.ResolvePath(String projectPath, String dotnetExePath)
at Buildalyzer.Environment.EnvironmentFactory.CreateCoreEnvironment(EnvironmentOptions options)
at Buildalyzer.Environment.EnvironmentFactory.GetBuildEnvironment(String targetFramework, EnvironmentOptions options)
at Buildalyzer.ProjectAnalyzer.Build(String targetFramework, EnvironmentOptions environmentOptions)
at MessagePack.CodeGenerator.RoslynExtensions.<>c__DisplayClass3_0.<GetWorkspace>b__0(ProjectAnalyzer p) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 83
at System.Linq.Parallel.SelectQueryOperator`2.SelectQueryOperatorResults.GetElement(Int32 index)
at System.Linq.Parallel.QueryResults`1.get_Item(Int32 index)
at System.Linq.Parallel.PartitionedDataSource`1.ListContiguousIndexRangeEnumerator.MoveNext(T& currentElement, Int32& currentKey)
at System.Linq.Parallel.WhereQueryOperator`1.WhereQueryOperatorEnumerator`1.MoveNext(TInputOutput& currentElement, TKey& currentKey)
at System.Linq.Parallel.StopAndGoSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
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.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
at System.Linq.Parallel.SpoolingTask.SpoolStopAndGo[TInputOutput,TIgnoreKey](QueryTaskGroupState groupState, PartitionedStream`2 partitions, SynchronousChannel`1[] channels, TaskScheduler taskScheduler)
at System.Linq.Parallel.MergeExecutor`1.Execute()
at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
at System.Linq.Parallel.WhereQueryOperator`1.WrapPartitionedStream[TKey](PartitionedStream`2 inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping, QuerySettings settings)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2 inputStream)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
at System.Linq.Parallel.QueryOperator`1.GetOpenedEnumerator(Nullable`1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings)
at System.Linq.Parallel.QueryOpeningEnumerator`1.OpenQuery()
at System.Linq.Parallel.QueryOpeningEnumerator`1.MoveNext()
at System.Linq.ParallelEnumerable.ToList[TSource](ParallelQuery`1 source)
at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspace(AnalyzerManager manager, EnvironmentOptions envOptions) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 81
at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspaceWithPreventBuildEvent(AnalyzerManager manager) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 67
at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject(String csprojPath, String[] preprocessorSymbols) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 26
at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable`1 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 89
I've merged PR, but check above error reports.
I've tested on following env and seems to work fine.
Hi there,
How can I build the new mpc file?
I've added binary to releases page.
Please try it. https://github.com/neuecc/MessagePack-CSharp/releases/tag/v.1.7.3.6
I have also tested the new mpc on MacOS with .NET core 2.1 project and working great.
Also hats off to finally update messagepack to work with .net standard 2.0 in unity - its working like a charm.
Thanks a lot 馃憤
I still have same result.
>./osx-x64/mpc -i /Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj -o ~/Desktop/Test.cs
Project Compilation Start:/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
/usr/local/share/dotnet/sdk/2.2.102/MSBuild.dll -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/2.2.102/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/2.2.102/dotnet.dll -maxcpucount -verbosity:m /v:n /bl:/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/__buildtemp/build.binlog /p:IntermediateOutputPath=/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/__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=/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj /t:ResolveAssemblyReferencesDesignTime;ResolveProjectReferencesDesignTime;ResolveComReferencesDesignTime;Compile /Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj
Build started 1/11/19 9:49:26 AM.
1>Project "/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj" on node 1 (ResolveAssemblyReferencesDesignTime;ResolveProjectReferencesDesignTime;ResolveComReferencesDesignTime;Compile target(s)).
1>/usr/local/share/dotnet/sdk/2.2.102/Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj]
1>Done Building Project "/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj" (ResolveAssemblyReferencesDesignTime;ResolveProjectReferencesDesignTime;ResolveComReferencesDesignTime;Compile target(s)) -- FAILED.
Deferred Messages
Detailed Build Summary
======================
============================== Build Hierarchy (IDs represent configurations) =====================================================
Id : Exclusive Time Total Time Path (Targets)
-----------------------------------------------------------------------------------------------------------------------------------
0 : 0.322s 0.479s /Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj (ResolveAssemblyReferencesDesignTime, ResolveProjectReferencesDesignTime, ResolveComReferencesDesignTime, Compile)
| 1 : 0.078s 0.078s /Users/kyubuns/code/MessagePack-CSharp/src/MessagePack/MessagePack.csproj (GetTargetFrameworks)
. 2 : 0.078s 0.078s /Users/kyubuns/code/MessagePack-CSharp/src/MessagePack/MessagePack.csproj (GetTargetPath)
============================== Node Utilization (IDs represent configurations) ====================================================
Timestamp: 1 Duration Cumulative
-----------------------------------------------------------------------------------------------------------------------------------
636827645665118780: 0 0.228s 0.228s ####
636827645667402490: 1 0.078s 0.306s #
636827645668181830: 0 0.055s 0.361s #
636827645668730300: 2 0.078s 0.439s #
636827645669509410: 0 0.042s 0.481s
-----------------------------------------------------------------------------------------------------------------------------------
Utilization: 100.0 Average Utilization: 100.0
Build FAILED.
"/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj" (ResolveAssemblyReferencesDesignTime;ResolveProjectReferencesDesignTime;ResolveComReferencesDesignTime;Compile target) (1) ->
(GetReferenceAssemblyPaths target) ->
/usr/local/share/dotnet/sdk/2.2.102/Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.49
execute `dotnet msbuild` failed, retry with `msbuild`
Project Compilation Complete:00:00:04.6108751
Method Collect Start
Method Collect Complete:00:00:00.0012670
Output Generation Start
[Out]/Users/kyubuns/Desktop/Test.cs
String Generation Complete:00:00:00.0067723
I have latest .NET Core SDK.
.NET Core SDK (reflecting any global.json):
Version: 2.2.102
Commit: 96ff75a873
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/2.2.102/
I investigated and same result in sandbox/SharedData/SharedData.csproj on linux , and I found suspicious point.
At least, output was fixed in linux.
Could you try it? @kyubuns
Thanks! But I still have same result on macOS.
I try Console.WriteLine(propargs) under your fix code.
/p:IntermediateOutputPath="/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/__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="/Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj/"
hmm, it seems to be difficult to resolve problem.
I added following changes for debugging.
Could you try again?
I try the code.
dotnet bin/Debug/netcoreapp2.1/mpc.dll -i /Users/kyubuns/code/MessagePack-CSharp/sandbox/SharedData/SharedData.csproj -o ~/Desktop/Test.cs > output.txt
output.txt
buildlog.zip - output.txt & build.binlog
Our game depends heavily on this fix...
We can't make it to work using MacOSX, same as @kyubuns ...
We are willing to pay for someone to fix that and close the issue...
@jkampitakis Our current workaround for the MacOSX compatibility issues is using a Parallels Desktop installation on the MacOS machine and running mpc.exe (older version, not the newest) from there. It's not pretty (and would probably be hard to run as part of a CI pipeline) but it does the trick if you really need it.
@mikkoairaksinen Ok. we can try that...Are you using version 1.7.3 from https://github.com/neuecc/MessagePack-CSharp/releases/tag/v1.7.3 ?
Yes. Haven't tried yet if 1.7.3.6 would work with Parallels, but I'd imagine there should be no problems there. I will try to update some time in the near future and can report back on the results.
Using VirtualBox with Windows10 installation and v1.7.3 we don't have an empty .cs file anymore but it's all wrong... The mapped classes aren't there, it just scans all the classes declared in the .csproj file and gives us useless generated data (I am attaching the files)
We also tried the v1.7.3.5 ( https://github.com/neuecc/MessagePack-CSharp/releases/download/v.1.7.3.5/MessagePackUniversalCodeGenerator.zip - win-x64 folder) that gives us the following error:
MessagePackGenerated.txt
Assembly-CSharp.csproj.txt
_### Unhandled Exception: System.AggregateException: One or more errors occurred. (One or more errors occurred. (The system cannot find the file specified)) (The system cannot find the file specified) ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Buildalyzer.Environment.ProcessRunner.Start()
at Buildalyzer.Environment.DotnetPathResolver.GetInfo(String projectPath, String dotnetExePath)
at Buildalyzer.Environment.DotnetPathResolver.ResolvePath(String projectPath, String dotnetExePath)
at Buildalyzer.Environment.EnvironmentFactory.CreateCoreEnvironment(EnvironmentOptions options)
at Buildalyzer.Environment.EnvironmentFactory.GetBuildEnvironment(String targetFramework, EnvironmentOptions options)
at Buildalyzer.ProjectAnalyzer.Build(String targetFramework, EnvironmentOptions environmentOptions)
at MessagePack.CodeGenerator.RoslynExtensions.<>c__DisplayClass3_0.
at System.Linq.Parallel.SelectQueryOperator2.SelectQueryOperatorResults.GetElement(Int32 index)
at System.Linq.Parallel.QueryResults1.get_Item(Int32 index)
at System.Linq.Parallel.PartitionedDataSource1.ListContiguousIndexRangeEnumerator.MoveNext(T& currentElement, Int32& currentKey)
at System.Linq.Parallel.WhereQueryOperator1.WhereQueryOperatorEnumerator1.MoveNext(TInputOutput& currentElement, TKey& currentKey)
at System.Linq.Parallel.StopAndGoSpoolingTask2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Linq.Parallel.QueryTask.RunTaskSynchronously(Object o)
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.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
at System.Linq.Parallel.SpoolingTask.SpoolStopAndGoTInputOutput,TIgnoreKey
at System.Linq.Parallel.DefaultMergeHelper2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute()
at System.Linq.Parallel.MergeExecutor1.Execute()
at System.Linq.Parallel.MergeExecutor1.Execute[TKey](PartitionedStream2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
at System.Linq.Parallel.PartitionedStreamMerger1.Receive[TKey](PartitionedStream2 partitionedStream)
at System.Linq.Parallel.WhereQueryOperator1.WrapPartitionedStream[TKey](PartitionedStream2 inputStream, IPartitionedStreamRecipient1 recipient, Boolean preferStriping, QuerySettings settings)
at System.Linq.Parallel.UnaryQueryOperator2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream2 inputStream)
at System.Linq.Parallel.UnaryQueryOperator2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient)
at System.Linq.Parallel.UnaryQueryOperator2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient)
at System.Linq.Parallel.QueryOperator1.GetOpenedEnumerator(Nullable1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings)
at System.Linq.Parallel.QueryOpeningEnumerator1.OpenQuery()
at System.Linq.Parallel.QueryOpeningEnumerator1.MoveNext()
at System.Linq.ParallelEnumerable.ToList[TSource](ParallelQuery1 source)
at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspace(AnalyzerManager manager, EnvironmentOptions envOptions) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 81
at MessagePack.CodeGenerator.RoslynExtensions.GetWorkspaceWithPreventBuildEvent(AnalyzerManager manager) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 67
at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject(String csprojPath, String[] preprocessorSymbols) in C:\GitHubRepositories\MessagePack-CSharp\src\MessagePack.UniversalCodeGenerator\Utils\RoslynExtensions.cs:line 26
at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable`1 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 89_
There might be an issue in the csproj file you pass as input to the mpc.exe. Ours is very simple, basically looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup>
<Reference Include="UnityEngine.CoreModule">
<HintPath>Library/UnityAssemblies/UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Compile Include="Assets/External/MessagePack/Attributes.cs" />
<Compile Include="Assets/Scripts/**/Shared/**/*.cs" />
</ItemGroup>
</Project>
I have been investigated about this problem, and successed reproducing.
my branch for investigation is here.
I found TypeCollector.targetTypes.Length is 0 even if compilation included valid MessagePackObject attribute.
It is because Compilation.GetTypeByMetadataName("[assembly name]") returns null,
but I still don't understand why null is returned.
I will continue the investigation.
I might find the cause of this issue.
The issue is occured in following conditions.
<ProjectReference/>If in above conditions, msbuild task is finished as success, but GetTypeByMetadataName returns null in ReferenceSymbols.ctor.
I think if GetTypeByMetadataName returns null, mpc should exit as error.
@neuecc @itn3000 what is the status of this issue?
For anyone still struggling with mac compatibility, here is the minimal dummy csproj I have managed to make work with the latest MsgPack version:
MessagePackResolverDummyProject.csproj
```
Replace the second path with whatever path you need to include all your code that must be visible. Run mpc with
`./mpc/osx-x64/mpc -i MessagePackResolverDummy.csproj -o [YOUR_PATH_HERE]`
Some random observations:
- Running this will for whatever reason always try to use .NET Framework instead of .NET Core and always produce an error and then immediately succeeding. You'll see something like this:
Build FAILED.
(ResolveAssemblyReferencesDesignTime;ResolveProjectReferencesDesignTime;ResolveComReferencesDesignTime;Compile target) (1) ->
(GetReferenceAssemblyPaths target) ->
/usr/local/share/dotnet/sdk/2.2.102/Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Time Elapsed 00:00:00.32
execute dotnet msbuild failed, retry with msbuild
Project Compilation Complete:00:00:06.1113588
Method Collect Start
Method Collect Complete:00:00:00.1633694
```
@mikkoairaksinen Thanks a lot!
I can confirm your solution is working and that we have exactly the same errors / problems as you 馃摕
Same issue here, any progress?
@mikkoairaksinen try replacing the PATH env variable of the process to match that of your command line.
ProcessStartInfo procInfo = new ProcessStartInfo();
procInfo.EnvironmentVariables["PATH"] = "<your_command_line_path>"
So is there any way to build a Unity game using this library for iOS? I have both windows machine and a macbook
@DataGreed why do you think there is none?
@hiradyazdan because I did not find any code generator version working on macOS
@DataGreed there were some issues, but I suspect it is mainly to do with what script/dll you use to build. I use below now and it works fine now:
MessagePackUniversalCodeGenerator/osx-x64/mpc.dll -i "whatever.csproj" -o "MessagePackGenerated.cs"
using the dll solved my issue at least. Let me know if this works for you.
Note: make sure to run it against dotnet only, and not mono as it's not supported.
https://github.com/neuecc/MessagePack-CSharp/issues/355#issuecomment-458420406
I still have same error on origin/master ( 6f5f80e2f56fd14627108e19830685450e8701f1 )
I build mpc.dll from source code.
> dotnet /Users/kyubuns/code/MessagePack-CSharp/bin/MessagePack.UniversalCodeGenerator/Debug/netcoreapp2.1/mpc.dll -i Game/Serializable.csproj -o test.cs
Project Compilation Start:Game/Serializable.csproj
Unhandled Error:System.IO.FileNotFoundException: Could not find file '/Users/kyubuns/code/Hoge/Game/Temp/bin/Debug/MessagePack.dll'.
File name: '/Users/kyubuns/code/Hoge/Game/Temp/bin/Debug/MessagePack.dll'
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 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/kyubuns/code/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 248
at MessagePack.CodeGenerator.RoslynExtensions.GetCompilationFromProject(String csprojPath, String[] preprocessorSymbols) in /Users/kyubuns/code/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Utils/RoslynExtensions.cs:line 283
at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable`1 conditinalSymbols, Boolean disallowInternal, Boolean isForceUseMap) in /Users/kyubuns/code/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs:line 186
at MessagePack.CodeGenerator.Program.Main(String[] args) in /Users/kyubuns/code/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Program.cs:line 31
@kyubuns have you referenced messagepack.dll in your csproj?
@hiradyazdan
Serializable.csproj has reference to MessagePack.csproj for MessagePackObjectAttribute, KeyAttribute.
There are created by assembly definition in Unity.
@kyubuns when using asmdefs, make sure you're not referencing MessagePack.dll in assembly definition references anywhere as your error says it can't find the messsagepack.dll.
One thing you need to know is that this is "pre code generation" and may not necessarily contain your built asmdef project as well.
Also, only add your MessagePack source codes to a directory (e.g. library) in Assets directory, as messagepack needs to be used with its source than dll in unity.
@hiradyazdan
I found this in MessagePack.csproj (generated by unity)
<OutputPath>Temp\bin\Debug\</OutputPath>
The path is lie. I overwrite to "Library/ScriptAssemblies/".
It looked like it worked.
Then I had other error.
Project Compilation Start:Game/Serializable.csproj
Unhandled Error:System.InvalidOperationException: failed to get metadata of System.Threading.Tasks.Task`1
at MessagePack.CodeGenerator.TypeCollector.ReferenceSymbols..ctor(Compilation compilation) in /Users/kyubuns/code/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs:line 917
at MessagePack.CodeGenerator.TypeCollector..ctor(String csProjPath, IEnumerable`1 conditinalSymbols, Boolean disallowInternal, Boolean isForceUseMap) in /Users/kyubuns/code/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs:line 193
at MessagePack.CodeGenerator.Program.Main(String[] args) in /Users/kyubuns/code/MessagePack-CSharp/src/MessagePack.UniversalCodeGenerator/Program.cs:line 31
I think this error was also up in this thread, do you know anything?
I don't think you have to change your output path. I would suggest build your project without asmdefs and and isolate your problem to main unity project template and then your current platform and then retry.
Also, probably would be worth to learn more about asmdefs first before jumping right into them.
Even myself, asmdef is only used for other benefits.
I solved this problem by creating a new csproj without unity.
Thanks for your advice.
Most helpful comment
For anyone still struggling with mac compatibility, here is the minimal dummy csproj I have managed to make work with the latest MsgPack version:
MessagePackResolverDummyProject.csproj
```
Build FAILED.
(ResolveAssemblyReferencesDesignTime;ResolveProjectReferencesDesignTime;ResolveComReferencesDesignTime;Compile target) (1) ->
(GetReferenceAssemblyPaths target) ->
/usr/local/share/dotnet/sdk/2.2.102/Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Time Elapsed 00:00:00.32
execute
dotnet msbuildfailed, retry withmsbuildProject Compilation Complete:00:00:06.1113588
Method Collect Start
Method Collect Complete:00:00:00.1633694
```