python3Packages.openusd: 24.08 -> 24.11 (#376119)
[NixPkgs.git] / pkgs / by-name / ro / roslyn-ls / package.nix
blob689b7002afe020c6760f67b37dff64de5e512b74
2   lib,
3   fetchFromGitHub,
4   buildDotnetModule,
5   dotnetCorePackages,
6   stdenvNoCC,
7   testers,
8   roslyn-ls,
9   jq,
11 let
12   pname = "roslyn-ls";
13   dotnet-sdk =
14     with dotnetCorePackages;
15     sdk_9_0
16     // {
17       inherit
18         (combinePackages [
19           sdk_9_0
20           sdk_8_0
21         ])
22         packages
23         targetPackages
24         ;
25     };
26   # need sdk on runtime as well
27   dotnet-runtime = dotnetCorePackages.sdk_9_0;
28   rid = dotnetCorePackages.systemToDotnetRid stdenvNoCC.targetPlatform.system;
30   project = "Microsoft.CodeAnalysis.LanguageServer";
32 buildDotnetModule rec {
33   inherit pname dotnet-sdk dotnet-runtime;
35   vsVersion = "2.62.18";
36   src = fetchFromGitHub {
37     owner = "dotnet";
38     repo = "roslyn";
39     rev = "VSCode-CSharp-${vsVersion}";
40     hash = "sha256-oy1xYM6Kd/8uAQQdvsxLNkycs9OOs7SEe+dzYc4RMeM=";
41   };
43   # versioned independently from vscode-csharp
44   # "roslyn" in here:
45   # https://github.com/dotnet/vscode-csharp/blob/main/package.json
46   version = "4.14.0-1.25060.2";
47   projectFile = "src/LanguageServer/${project}/${project}.csproj";
48   useDotnetFromEnv = true;
49   nugetDeps = ./deps.json;
51   nativeBuildInputs = [ jq ];
53   patches = [
54     # until upstream updates net6.0 here:
55     # https://github.com/dotnet/roslyn/blob/6cc106c0eaa9b0ae070dba3138a23aeab9b50c13/eng/targets/TargetFrameworks.props#L20
56     ./force-sdk_8_0.patch
57     # until made configurable/and or different location
58     # https://github.com/dotnet/roslyn/issues/76892
59     ./cachedirectory.patch
60   ];
62   postPatch = ''
63     # Upstream uses rollForward = latestPatch, which pins to an *exact* .NET SDK version.
64     jq '.sdk.rollForward = "latestMinor"' < global.json > global.json.tmp
65     mv global.json.tmp global.json
66   '';
68   dotnetFlags = [
69     "-p:TargetRid=${rid}"
70     # this removes the Microsoft.WindowsDesktop.App.Ref dependency
71     "-p:EnableWindowsTargeting=false"
72   ];
74   # two problems solved here:
75   # 1. --no-build removed -> BuildHost project within roslyn is running Build target during publish
76   # 2. missing crossgen2 7.* in local nuget directory when PublishReadyToRun=true
77   # the latter should be fixable here but unsure how
78   installPhase = ''
79     runHook preInstall
81     env dotnet publish $dotnetProjectFiles \
82         -p:ContinuousIntegrationBuild=true \
83         -p:Deterministic=true \
84         -p:InformationalVersion=$version \
85         -p:UseAppHost=true \
86         -p:PublishTrimmed=false \
87         -p:PublishReadyToRun=false \
88         --configuration Release \
89         --no-self-contained \
90         --output "$out/lib/$pname" \
91         --no-restore \
92         --runtime ${rid} \
93         ''${dotnetInstallFlags[@]}  \
94         ''${dotnetFlags[@]}
96     runHook postInstall
97   '';
99   passthru = {
100     tests.version = testers.testVersion { package = roslyn-ls; };
101     updateScript = ./update.sh;
102   };
104   meta = {
105     homepage = "https://github.com/dotnet/vscode-csharp";
106     description = "Language server behind C# Dev Kit for Visual Studio Code";
107     changelog = "https://github.com/dotnet/vscode-csharp/releases/tag/v${vsVersion}";
108     license = lib.licenses.mit;
109     maintainers = with lib.maintainers; [ konradmalik ];
110     mainProgram = "Microsoft.CodeAnalysis.LanguageServer";
111   };