AArnott / CodeGeneration.Roslyn

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

Make tool working with compatible versions #230

Closed Pzixel closed 4 years ago

Pzixel commented 4 years ago

In current version of the tool any newer version of netcore installed doesn't fit library requirements. For example, this is how samples work on my machine:

PS C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master> .\build.ps1
.\build.ps1: The term '.\build.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master> cd .\samples\
PS C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\samples> .\build.ps1
Running in C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\samples
A compatible installed .NET Core SDK for global.json version [3.1.100] from [C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\global.json] was not found
Install the [3.1.100] .NET Core SDK or update [C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\global.json] with an installed .NET Core SDK:
Using CG.R package version:   3.1.301 [C:\Program Files\dotnet\sdk]
Get-ChildItem: C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\samples\build.ps1:28
Line |
  28 |  … $cgrNupkg = Get-ChildItem ../bin/Packages/$env:Configuration/ -Filter …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\bin\Packages\Debug\' because
     | it does not exist.

CG.R packages for this version not found, packing...
dotnet pack ../src
A compatible installed .NET Core SDK for global.json version [3.1.100] from [C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\global.json] was not found
Install the [3.1.100] .NET Core SDK or update [C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\global.json] with an installed .NET Core SDK:
  3.1.301 [C:\Program Files\dotnet\sdk]
BuildPropsGenerator/build.ps1
Running in C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\samples\BuildPropsGenerator
dotnet build
A compatible installed .NET Core SDK for global.json version [3.1.100] from [C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\global.json] was not found
Install the [3.1.100] .NET Core SDK or update [C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\global.json] with an installed .NET Core SDK:
  3.1.301 [C:\Program Files\dotnet\sdk]
dotnet pack JsonGenerator
A compatible installed .NET Core SDK for global.json version [3.1.100] from [C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\global.json] was not found
Install the [3.1.100] .NET Core SDK or update [C:\Users\pzixe\Downloads\CodeGeneration.Roslyn-master\global.json] with an installed .NET Core SDK:
  3.1.301 [C:\Program Files\dotnet\sdk]
PackagedGenerator/build.ps1
...

The problem is that docker users don't controll installed SDK version. For example, typical dockerfile generated by VS is something like this:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src

And there is no way to specify exact version, or at least any changes get lost when file is regenerated, which is very tedious to maintain.

Is it possible to make tool compatible with any patch version?

amis92 commented 4 years ago

Closed by https://github.com/AArnott/CodeGeneration.Roslyn/commit/1f8c17ddbd8e9b0c862fdec184494fedcca7da7f