cezarypiatek / MappingGenerator

:arrows_counterclockwise: "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.mappinggenerator
MIT License
1.03k stars 120 forks source link

Fix NuGet package OnBuildGenerator #166

Open MisinformedDNA opened 3 years ago

MisinformedDNA commented 3 years ago

Mapping Generator Version [Current]

Mapping Generator distribution NugetPackage

IDE type and version Visual Studio 2019 16.8

Describe the incorrect behavior The MappingGenerator.OnBuildGenerator on NuGet is broken. Running the code from this test case, results in 3 errors, such as

The type or namespace name 'OnBuildGenerator' does not exist in the namespace 'MappingGenerator' (are you missing an assembly reference?)

Describe the expected behavior No compilation issues.

Screenshots image

cezarypiatek commented 3 years ago

Hi, The MappingGenerator.OnBuildGenerator assembly is not added to project dependencies. You need to copy the attribute definition directly to your source code. Please follow this guideline to set up OnBuildGenerator correctly https://cezarypiatek.github.io/post/generate-mappings-on-build/#generate-mapping-code-on-build

Please let me know if you still have any troubles.

Have a nice day, Cezary

MisinformedDNA commented 3 years ago

@cezarypiatek Thanks for the response. I get this error when adding SmartCodeGenerator.Engine:

MSB3073 The command "C:\Users\50587.nuget\packages\smartcodegenerator.engine\1.4.23\build\/../tools/SmartCodeGenerator.Engine.exe -p C:\Users\50587\source\repos\MappingGeneratorPoC\MappingGeneratorPoC\MappingGeneratorPoC.csproj -o C:\Users\50587\source\repos\MappingGeneratorPoC\MappingGeneratorPoC\obj\Debug\netcoreapp3.1\ -g C:\Users\50587.nuget\packages\mappinggenerator.onbuildgenerator\1.22.1.18\build\/../tools/MappingGenerator.OnBuildGenerator.dll" exited with code -532462766. MappingGeneratorPoC C:\Users\50587.nuget\packages\smartcodegenerator.engine\1.4.23\build\SmartCodeGenerator.Engine.targets 11

cezarypiatek commented 3 years ago

Can you attach a sample solution that reproduces this problem?

MisinformedDNA commented 3 years ago

MappingPoC.zip