Skip to content

Commit 0619453

Browse files
committed
C#: Explicitly set .NET 5.0 as target framework in class lib and hardcode compilation to use version 5.0.402 of the SDK
1 parent c91b6f7 commit 0619453

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

csharp/ql/src/Stubs/make_stubs_nuget.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def write_csproj_prefix(ioWrapper):
1717

1818

1919
print('Script to generate stub file from a nuget package')
20-
print(' Usage: python ' + sys.argv[0] +
20+
print(' Usage: python3 ' + sys.argv[0] +
2121
' NUGET_PACKAGE_NAME [VERSION=latest] [WORK_DIR=tempDir]')
2222
print(' The script uses the dotnet cli, codeql cli, and dotnet format global tool')
2323

@@ -57,7 +57,7 @@ def write_csproj_prefix(ioWrapper):
5757
version = helpers.get_argv(2, "latest")
5858

5959
print("\n* Creating new input project")
60-
helpers.run_cmd(['dotnet', 'new', 'classlib', "--language", "C#", '--name',
60+
helpers.run_cmd(['dotnet', 'new', 'classlib', "-f", "net5.0", "--language", "C#", '--name',
6161
projectNameIn, '--output', projectDirIn])
6262
helpers.remove_files(projectDirIn, '.cs')
6363

@@ -68,9 +68,13 @@ def write_csproj_prefix(ioWrapper):
6868
cmd.append(version)
6969
helpers.run_cmd(cmd)
7070

71+
sdk_version = '5.0.402'
72+
print("\n* Creating new global.json file and setting SDK to " + sdk_version)
73+
helpers.run_cmd(['dotnet', 'new', 'globaljson', '--force', '--sdk-version', sdk_version])
74+
7175
print("\n* Creating DB")
7276
helpers.run_cmd(['codeql', 'database', 'create', dbDir, '--language=csharp',
73-
'--command', 'dotnet build /t:rebuild ' + projectDirIn])
77+
'--command', 'dotnet build /t:rebuild /p:UseSharedCompilation=false ' + projectDirIn])
7478

7579
if not os.path.isdir(dbDir):
7680
print("Expected database directory " + dbDir + " not found.")

0 commit comments

Comments
 (0)