Closed Antaris closed 4 years ago
Analysis on my part:
Looking at https://github.com/AArnott/CodeGeneration.Roslyn/blob/246ca6a3a01b24f2793293f03ed80e99a7ba0ed1/src/CodeGeneration.Roslyn.Engine/DocumentTransform.cs#L131 and below, the reasons can be the following:
In any other case, there should be some errors. Can you try to look at verbose logs?
I have a problem that might be related to this one. I just have a very primitive (on purpose) code generator (inspired by on of the examles of this repro). I have a public accessible pull request: https://github.com/Qowaiv/qowaiv-codegenerator/pull/1/commits/e681d63945cace1effe35ed8ef0c41cbcf71f18c
In my output I noticed the following ERROR:
MSB3073 The command "dotnet codegen "@obj\Debug\netstandard2.0\Qowaiv.CodeGenerator.Examples.csproj.dotnet-codegen.rsp"" exited with code 3.
This was after I added a global.json:
{
"sdk": { "version": "2.2.402" },
"msbuild-sdks": {
"Microsoft.Build.CentralPackageVersions": "2.0.46"
}
}
Without, I've got the following error:
Error occurred while restoring NuGet packages: Failed to retrieve information about 'dotnet-codegen' from remote source (..)
@Corniel Your issue seems to be super different actually. Could you open up a new one?
Error 3 means an exception was caught - it should log details in the msbuild log.
As per this specific issue, closing because of no follow-up from OP.
This one might be hard to solve, so I appreciate any and all comments 👍
I'm developing a custom generator to allow me to flesh out some custom primitives we use internally for our business system.
When I develop locally, I can see my custom code being generated in my unit tests. When I ship my generator as a package, I get an (almost) empty generated file:
There is no actual implementation in the generated file.
My delivery mechanism is as follows:
MyBusiness.CodeGeneration.Abstractions
package containing shared code generation abstractions which can be consumed by any custom generators I build.MyBusiness.CodeGeneration.Attributes
package containing marker attributesMyBusiness.CodeGeneration.Generator
package containing my struct generator.In addition, I generate a meta-package,
MyBusiness.CodeGeneration
which pulls in my dependencies:When I build this while consuming my packages (meta or direct), it only ever generates an empty file.
Things I've checked:
*Generator
package containsbuild\MyBusiness.CodeGeneration.Generator.props
with reference to$(MSBuildThisFileDirectory)..\tools
*Generator
package containstools\MyBusiness.CodeGeneration.Generator.dll
PrivateAssets="all"
on all packages (except*Attributes
).I'm struggling to understand why it won't run my generator. Previously when I hadn't correctly included my generator assembly, it gave my an exception, but now it is happy the assembly exists, but nothing is generated.
An example of my code:
This was based on
StronglyTypedId
by Andrew Lock (https://github.com/andrewlock/StronglyTypedId) which uses your packages. The only real difference between his implementation and mine is that I am using embedded template files instead of manually generating the syntax myself, therefore I have a direct dependency onMicrosoft.Extensions.FileProviders.Embedded
Other things to note:
tools
? - I would imagine if it couldn't load dependent assemblies, it would throw an exception?