AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 59 forks source link

"dotnet" exited with code 1 #81

Closed joaommvsoares closed 5 years ago

joaommvsoares commented 6 years ago

Hello,

My sample works fine in version 0.3.9, but when I try with 0.4.49 it trows the error at compile time:

1> No executable found matching command "dotnet-codegen" 1>C:\Trabalho\Porjs\GeneratedCode\packages\CodeGeneration.Roslyn.BuildTime.0.4.49\build\CodeGeneration.Roslyn.BuildTime.targets(20,5): error MSB6006: "dotnet" exited with code 1.

I even tried to include at project:

I used VS21017 to CodeGenerator.DLL and VS2015 to use it on GeneratedCode.exe (my final project must be in VS2015 for now…)

What seems to be the problem?

Thanks, João Miguel

amis92 commented 6 years ago

No executable found matching command "dotnet-codegen"

That sounds like you need to add to <ItemGroup> element in your project this reference:

    <DotNetCliToolReference Include="dotnet-codegen" Version="0.4.49" />

But also, I'm pretty sure that your consuming project (GeneratedCode) must be compiled with VS2017 /dotnet CLI from .NET Core SDK v2.0+

Until you can upgrade VS version you use to VS2017, I think you cannot update this tool.

joaommvsoares commented 6 years ago

I tried that, but It doen't work. It throws an error with tag version.

amis92 commented 6 years ago

Are you using the SDK-style csproj?

The file should start with

<Project Sdk="Microsoft.NET.Sdk">
…

If you are, please attach the error you see. This DotNetCliToolReference is required.

amis92 commented 5 years ago

Re-reading the original post: using the generator requires running dotnet codegen DotNetCliTool which is only available if the project that's supposed to run it has DotNetCliToolReference. In turn, that element is only supported in SDK-style csproj files, which in turn again are only supported in VS2017.

TLDR this project only works in VS2017+ all the way.