Problems migrating to 0.7 via generator inside NuGet package #195
Comments
Quick answer: try to look at demo from README https://github.com/AArnott/CodeGeneration.Roslyn#how-to-write-your-own-code-generator Longer answer: |
I have been going around in circles trying to make this work. I spent 4 hours last week trying to make it work, had to pause it, and have come back to it again to try, even with the basic settings, to get something moving and it's going nowhere. After trying to get the complex multi-target nu-get version working (which I don't see how it could ever work when there's only one props in the package pointing to one target and Today: Code-generator project file: <Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build">
<PropertyGroup>
<RoslynCodeGenVersion>0.7.5-alpha</RoslynCodeGenVersion>
</PropertyGroup>
<Sdk Name="CodeGeneration.Roslyn.Plugin.Sdk" Version="0.7.5-alpha" />
<PropertyGroup>
<PackageVersion>3.4.5</PackageVersion>
<PackageId>LanguageExt.CodeGen</PackageId>
<Title>LanguageExt.CodeGen</Title>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CodeGeneration.Roslyn" Version="$(RoslynCodeGenVersion)" />
</ItemGroup>
</Project> The attributes project file: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.0;net461</TargetFrameworks>
<PackageVersion>3.4.5</PackageVersion>
<PackageId>LanguageExt.CodeGen.Attributes</PackageId>
<OutputType>library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CodeGeneration.Roslyn.Attributes" Version="[0.7.5-alpha, )" />
</ItemGroup>
</Project> After dotnet pack I create an empty <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LanguageExt.CodeGen"
Version="3.4.5"
PrivateAssets="all" />
<PackageReference Include="LanguageExt.CodeGen.Attributes"
Version="3.4.5"
PrivateAssets="all" />
<PackageReference Include="CodeGeneration.Roslyn.BuildTime"
Version="0.7.5-alpha"
PrivateAssets="all" />
<DotNetCliToolReference Include="dotnet-codegen"
Version="0.7.5-alpha" />
</ItemGroup>
</Project>
And get:
If I open up the package in NuGet Package Explorer, there's a props file in the build folder: <?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CodeGenerationRoslynPlugin Include="$(MSBuildThisFileDirectory)../tools/netcoreapp2.1/any/LanguageExt.CodeGen.dll" />
</ItemGroup>
</Project> And a So, if I then change the
I figure something is being cached somewhere, because the nuget file has 3.0 refs in it. So, I create a new ConsoleApp and get the same.
Then, just for the hell of it, I try
I also tried So, then I tried (in the generator project file). And increased the version number to <TargetFrameworks>netcoreapp2.1;netcoreapp3.0</TargetFrameworks> This throws out the following warning:
That seems to imply that only one target can exist in a nuget package. This is very, very poor. If I open it up in Package Explorer I see two tools folders for If I set the console-app to look at the new package (with netcoreapp3.0 still set for its framework) I get:
So, it's complaining that If I change the console-app back to
I am yet to get anywhere close to getting a package working. Perhaps I'm missing something, but I can't help feeling this has all got a lot more complex than it perhaps needs to be. Certainly, the inability to support multiple targets seems to be a major step backwards, although just getting one working would be nice right now. It seems a PhD in project files is needed, which may work for the authors of this project, but is pretty impenetrable for the rest of us. |
@louthy your problem sounds a bit like what is presented in https://github.com/AArnott/CodeGeneration.Roslyn#multitargeting-generator Does it solve your problem? Also, because we are a tool, we can't really multi-target. That's why the limitation exists, and the link describes how to workaround it. |
But I can’t even target one platform successfully. Is there anything in particular there that you’re referring to, because my comments above are a fraction of the attempts I’ve tried to make this work, trying all combos of settings I could. If I could make it work for one platform I would at least have some idea of whether I was on the right track or not. I just updated visual studio too to see if there was something going awry there, but now visual studio doesn’t recognise my c# projects (!!!), so right now I’m pretty frustrated and will probably have to roll back to the last version and will wait for others to have successes or look for alternative code-gen solutions. One thing to note from the documentation: there are often references to project files without being explicit as to whether it’s the generator project, consuming project, or attributes project, so assumptions are made in an attempt to decipher. Some clarity in the language could help, maybe. |
Well for what it's worth, I'm investigating what's going on. From the looks of it, it may be the case that my design for the Plugins is flawed and cannot work. Please bear with me, but since it's shaping up as a core design flaw, it'll probably take time to resolve. As in, days or weeks. :( |
Sure, thanks for letting me know. I have attached my |
This specific issue will be resolved via #198. |
I see the 'NuGet generator publisher' section of the migrations page isn't complete yet. I am seeing problems consuming the nuget package.
The issues are the same as previously reporting with the Project-to-Project solution. Any chance of getting that bit of documentation completed?
The text was updated successfully, but these errors were encountered: