AArnott / CodeGeneration.Roslyn

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

Walkthrough fails #60

Closed mbabramo closed 6 years ago

mbabramo commented 6 years ago

I followed the steps in the walkthrough and then also followed the advice from issue 54. A repo is here. The code is targeting .Net Framework 4.7.1 (eventually, I would like to target .Net Core 2.1, but ran into problems even when I removed this as target references).

The error produced is: "dotnet" exited with code -2147450730.

The following error was included in verbose output: 2> It was not possible to find any compatible framework version 2> The specified framework 'Microsoft.NETCore.App', version '1.0.4' was not found.

However, when I set the SDK version back to 2.0.2, I instead received an error that "dotnet" exited with code 1.

This may be related to an issue I separately posted.

mbabramo commented 6 years ago

As I've experimented more, I realize that my account above is too simplistic. I briefly had a time when I got everything to work. Then, to see if it was stable, I deleted the bin and obj folders and did a dot net restore and a dot net msbuild (or just dot net build or just build in Visual Studio). And then there would be something wrong.

I've tried various combinations of target frameworks, including make both projects target .Net Framework 4.7.1 only (which worked at first but then stopped working), and I've tried working in both Visual Studio 15.5.7 as well as the current Visual Studio 15.7 Preview 2. Meanwhile, what goes wrong seems to change. Sometimes, I get errors (including now an exit with code -532462766, which seems not to appear on Google). At other times, it will build but it won't work. For example, I'll see a generated file but the file doesn't contain the code that should be there (e.g., Foo with its suffix); it just has the comments about being an automatically created file. My theory is that the artifacts in bin and obj determine what goes right or wrong, but I haven't yet figured out any consistent patterns.

amis92 commented 6 years ago

I've tried your sample repo and it builds for me. I think I had to do a rebuild once, though. My Visual Studio is 2017 v15.6.5, no custom setup.

mbabramo commented 6 years ago

Thank you. I tried building on an untouched Windows 10 and Visual Studio, and this time it ran for me as well. So I'm not sure what the problem is or whether it is likely to crop up again.