ScriptCollection 4.4.10__py3-none-any.whl → 4.4.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -331,6 +331,27 @@ def UpdateDependencies() -> int:
331
331
  t.update_dependencies()
332
332
  return 0
333
333
 
334
+ def UpdateLockFilesOfDotNetCodeUnits() -> int:
335
+ parser = argparse.ArgumentParser(description="Restores the projects of every dotnet-codeunit of a repository and writes what was resolved into their lock-files. Run this after a dependency was changed on purpose: the build restores in locked mode and reports a project which asks for something else than its lock-file states with NU1004.")
336
+ parser.add_argument('-r', '--repositoryfolder', required=False, default=".", help="Folder of the repository. Defaults to the current working directory.")
337
+ verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
338
+ parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
339
+ args = parser.parse_args()
340
+ repository_folder: str = GeneralUtilities.resolve_relative_path(args.repositoryfolder, os.getcwd())
341
+ sc: ScriptCollectionCore = ScriptCollectionCore()
342
+ sc.log.loglevel = LogLevel(int(args.verbosity))
343
+ tools: TFCPS_Tools_General = TFCPS_Tools_General(sc)
344
+ amount_of_updated_codeunits: int = 0
345
+ for codeunit_name in tools.get_codeunits(repository_folder):
346
+ codeunit_folder: str = os.path.join(repository_folder, codeunit_name)
347
+ # a codeunit without a solution is one of another kind (an image, a frontend, ...) and has no lock-files
348
+ if os.path.isfile(os.path.join(codeunit_folder, f"{codeunit_name}.sln")):
349
+ tools.update_lock_files_of_dotnet_codeunit(codeunit_folder)
350
+ amount_of_updated_codeunits = amount_of_updated_codeunits+1
351
+ if amount_of_updated_codeunits == 0:
352
+ sc.log.log(f"The repository \"{repository_folder}\" contains no dotnet-codeunit, so there is no lock-file to update.", LogLevel.Warning)
353
+ return 0
354
+
334
355
  def UpdateDependenciesC() -> int:
335
356
  parser = argparse.ArgumentParser()
336
357
  parser.add_argument('-r','--repositoryfolder', required=False, default=".")
@@ -39,7 +39,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
39
39
  from .ProgramRunnerPopen import ProgramRunnerPopen
40
40
  from .SCLog import SCLog, LogLevel
41
41
 
42
- version = "4.4.10"
42
+ version = "4.4.12"
43
43
  __version__ = version
44
44
 
45
45
  class VSCodeWorkspaceShellTask:
@@ -6,7 +6,7 @@ import json
6
6
  from lxml import etree
7
7
  import yaml
8
8
  from .CertificateGeneratorInformationBase import CertificateGeneratorInformationBase
9
- from ...GeneralUtilities import GeneralUtilities
9
+ from ...GeneralUtilities import GeneralUtilities, VersionEcholon
10
10
  from ...SCLog import LogLevel
11
11
  from ..PackageSource import PackageSource
12
12
  from ..TFCPS_CodeUnitSpecific_Base import TFCPS_CodeUnitSpecific_Base,TFCPS_CodeUnitSpecific_Base_CLI
@@ -100,7 +100,30 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
100
100
  return url.strip().rstrip("/").lower() == other_url.strip().rstrip("/").lower()
101
101
 
102
102
  @GeneralUtilities.check_arguments
103
- def build(self,runtimes:list[str],generate_open_api_spec:bool) -> None:
103
+ def get_runtimes(self) -> list[str]:
104
+ """Returns the runtimes this codeunit is built for.
105
+
106
+ They are stated by the project-file itself (RuntimeIdentifiers). That is the one place which has to know them
107
+ anyway: the restore resolves the dependencies of exactly these runtimes, and an ide reads the same file. A
108
+ second list somewhere else could differ from it, and a build for a runtime which the project does not state has
109
+ no dependencies."""
110
+ content: str = GeneralUtilities.read_text_from_file(self.csproj_file)
111
+ result: list[str] = []
112
+ for entry in re.findall(r"<RuntimeIdentifiers>([^<]*)</RuntimeIdentifiers>", content):
113
+ for runtime in entry.split(";"):
114
+ runtime = runtime.strip()
115
+ # an empty entry (a superfluous semicolon for example) is stated and not skipped: it is a mistake in the
116
+ # declaration, and a declaration which is read differently than it is written is worse than an error.
117
+ GeneralUtilities.assert_condition(0 < len(runtime), f"The project \"{self.csproj_file}\" states an empty runtime in \"{entry}\".")
118
+ if runtime not in result:
119
+ result.append(runtime)
120
+ if len(result) == 0:
121
+ raise ValueError(f"The project \"{self.csproj_file}\" does not state the runtimes it is built for. Add \"<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>\" (with the runtimes of this codeunit) to the project-file.")
122
+ return result
123
+
124
+ @GeneralUtilities.check_arguments
125
+ def build(self,generate_open_api_spec:bool) -> None:
126
+ runtimes: list[str] = self.get_runtimes()
104
127
  if self.is_library:
105
128
  self.standardized_tasks_build_for_dotnet_library_project(runtimes)
106
129
  GeneralUtilities.assert_condition(not generate_open_api_spec,"OpenAPI-Specification can not be generated for a library.")
@@ -164,47 +187,51 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
164
187
  return value
165
188
 
166
189
  @GeneralUtilities.check_arguments
167
- def __get_lock_file_name(self, runtime: str) -> str:
168
- """Returns the name of the lock-file which belongs to the given runtime.
190
+ def __get_lock_file_name(self) -> str:
191
+ """Returns the name of the lock-file of a project.
169
192
 
170
- Every runtime needs its own lock-file: the lock-file records the set of runtime-identifiers it was created for, and a
171
- restore in locked mode fails with NU1004 when that set differs from the one which is currently restored (the restore
172
- gets exactly one runtime via "--runtime"). The name is relative, so NuGet resolves it per project - a restore over the
173
- solution therefore creates one lock-file next to each of the two project-files instead of letting them collide."""
174
- return f"packages.{runtime}.lock.json"
193
+ There is exactly one, and it carries the name nuget uses on its own. A codeunit is built for more than one runtime, but
194
+ the runtime is not part of the restore anymore: the projects state their runtimes (see
195
+ __assert_projects_state_their_runtimes), so one restore resolves all of them and writes one lock-file which knows all of
196
+ them. Every operation - the build, the linting, the testcases, the reference, and a developer who builds in an ide -
197
+ therefore reads and writes the same file, and none of them has to be kept away from it."""
198
+ return "packages.lock.json"
175
199
 
176
200
  @GeneralUtilities.check_arguments
177
- def __get_lock_file_arguments(self, codeunit_folder: str, codeunit_name: str, runtime: str) -> list[str]:
178
- """Returns the restore-arguments which pin the dependencies of the given runtime to the content of its lock-files.
201
+ def __ensure_lock_files_exist(self, codeunit_folder: str, codeunit_name: str) -> None:
202
+ """Creates the lock-files of the codeunit when they do not exist yet.
179
203
 
180
- Locked mode is only requested when the lock-file of every project of the codeunit already exists, because a restore in
181
- locked mode can not create one. A codeunit which does not have them yet is restored without it and gets a warning, so
182
- introducing the lock-files does not break the build of a codeunit which was not migrated yet."""
183
- lock_file_name: str = self.__get_lock_file_name(runtime)
204
+ The restore of the build runs in locked mode, and a restore in locked mode can not create a lock-file - it needs one.
205
+ A codeunit which does not have them yet (because it was just created, or because it was not migrated yet) therefore
206
+ gets them here, so introducing the lock-files does not break its build. They are stated as a warning, because a
207
+ lock-file which is not committed pins nothing on the next machine."""
208
+ lock_file_name: str = self.__get_lock_file_name()
184
209
  expected_lock_files: list[str] = [os.path.join(codeunit_folder, project_name, lock_file_name) for project_name in [codeunit_name, codeunit_name+"Tests"]]
185
210
  missing_lock_files: list[str] = [lock_file for lock_file in expected_lock_files if not os.path.isfile(lock_file)]
186
- result: list[str] = [f"-p:NuGetLockFilePath={lock_file_name}"]
187
- if len(missing_lock_files) == 0:
188
- result.append("--locked-mode")
189
- else:
190
- self._protected_sc.log.log(f"The dependencies of codeunit \"{codeunit_name}\" are not restored in locked mode for the runtime \"{runtime}\", because the following lock-file(s) do not exist yet: {', '.join(missing_lock_files)}. The restore creates them now; commit them so that the dependencies of this codeunit are pinned.", LogLevel.Warning)
191
- return result
192
-
193
- @GeneralUtilities.check_arguments
194
- def __get_arguments_which_prevent_writing_a_lock_file(self) -> list[str]:
195
- """Returns the arguments which keep a dotnet-operation from writing a lock-file into the codeunit.
196
-
197
- The lock-files belong to the restore of the build alone, because only there the runtime - and with it the name of the
198
- lock-file which belongs to that runtime - is known. Every other dotnet-operation of a codeunit (linting, test, ...)
199
- works on the solution instead of on one runtime and restores implicitly, and the csproj-property
200
- "RestorePackagesWithLockFile" would make each of those restores write a lock-file under the default-name next to the
201
- runtime-specific ones.
202
- The lock-file of those operations is therefore pointed at a throwaway-path outside of the repository. Switching the
203
- property off instead does not work: nuget rejects a restore with NU1005 as soon as a lock-file under the default-name
204
- exists, which is exactly the case this has to survive (a developer who ran "dotnet build" once has such a file). The
205
- value has to be passed on the command-line, because a property which the project-file sets explicitly wins over one
206
- which comes from the environment."""
207
- return [f"-p:NuGetLockFilePath={self.tfcps_Tools_General.get_throwaway_lock_file(self.get_codeunit_name())}"]
211
+ if 0 < len(missing_lock_files):
212
+ self._protected_sc.log.log(f"The following lock-file(s) of codeunit \"{codeunit_name}\" do not exist yet: {', '.join(missing_lock_files)}. They are created now; commit them so that the dependencies of this codeunit are pinned.", LogLevel.Warning)
213
+ self.tfcps_Tools_General.update_lock_files_of_dotnet_codeunit(codeunit_folder)
214
+
215
+ @GeneralUtilities.check_arguments
216
+ def __assert_projects_state_their_runtimes(self, csproj_file: str, runtimes: list[str]) -> None:
217
+ """Ensures that the given project states the runtimes it is built for.
218
+
219
+ The runtimes come from the project-file of the codeunit itself (see get_runtimes), so this checks the test-project:
220
+ it is built for the same runtimes and needs the same declaration. The build restores once without naming a runtime
221
+ and builds each runtime from that result - a project which does not state a runtime gets no dependencies for it and
222
+ fails with NETSDK1047, which names the assets-file and not the missing declaration. It is checked here instead,
223
+ where the reason and the remedy can be stated."""
224
+ content: str = GeneralUtilities.read_text_from_file(csproj_file)
225
+ declared_runtimes: list[str] = re.findall(r"<RuntimeIdentifiers>([^<]*)</RuntimeIdentifiers>", content)
226
+ declared: set[str] = set()
227
+ for entry in declared_runtimes:
228
+ for runtime in entry.split(";"):
229
+ runtime = runtime.strip()
230
+ GeneralUtilities.assert_condition(0 < len(runtime), f"The project \"{csproj_file}\" states an empty runtime in \"{entry}\".")
231
+ declared.add(runtime)
232
+ missing: list[str] = [runtime for runtime in runtimes if runtime not in declared]
233
+ if 0 < len(missing):
234
+ raise ValueError(f"The project \"{csproj_file}\" is built for the runtime(s) {', '.join(missing)}, but does not state them. Add \"<RuntimeIdentifiers>{';'.join(runtimes)}</RuntimeIdentifiers>\" to the project-file, so that the restore of the codeunit resolves the dependencies of these runtimes.")
208
235
 
209
236
  @GeneralUtilities.check_arguments
210
237
  def __standardized_tasks_build_for_dotnet_build(self, csproj_file: str, originaloutputfolder: str, files_to_sign: dict[str, str], commitid: str, runtimes: list[str], target_environmenttype_mapping: dict[str, str], copy_license_file_to_target_folder: bool, repository_folder: str, codeunit_name: str) -> None:
@@ -220,13 +247,18 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
220
247
  GeneralUtilities.ensure_directory_exists(sarif_folder)
221
248
  gitkeep_file = os.path.join(sarif_folder, ".gitkeep")
222
249
  GeneralUtilities.ensure_file_exists(gitkeep_file)
250
+ self.__assert_projects_state_their_runtimes(csproj_file, runtimes)
251
+ # One restore for all runtimes, before the first of them is built: the projects state their runtimes, so this restore
252
+ # resolves the dependencies of every one of them and writes one lock-file which knows them all. A restore per runtime
253
+ # ("--runtime") would narrow the project to that one runtime and contradict that file with NU1004.
254
+ GeneralUtilities.ensure_directory_does_not_exist(os.path.join(csproj_file_folder, "obj"))
255
+ self._protected_sc.run_program("dotnet", "clean", csproj_file_folder)
256
+ self.__ensure_lock_files_exist(codeunit_folder, codeunit_name)
257
+ self._protected_sc.run_program_argsasarray("dotnet", ["restore", "--locked-mode"], codeunit_folder,print_live_output=self.get_verbosity()==LogLevel.Debug)
223
258
  for runtime in runtimes:
224
259
  outputfolder = originaloutputfolder+runtime
225
- GeneralUtilities.ensure_directory_does_not_exist(os.path.join(csproj_file_folder, "obj"))
226
260
  GeneralUtilities.ensure_directory_does_not_exist(outputfolder)
227
- self._protected_sc.run_program("dotnet", "clean", csproj_file_folder)
228
261
  GeneralUtilities.ensure_directory_exists(outputfolder)
229
- self._protected_sc.run_program_argsasarray("dotnet", ["restore", "--runtime", runtime]+self.__get_lock_file_arguments(codeunit_folder, codeunit_name, runtime), codeunit_folder,print_live_output=self.get_verbosity()==LogLevel.Debug)
230
262
  self._protected_sc.run_program_argsasarray("dotnet", ["build", "--no-restore", csproj_file_name, "-c", dotnet_build_configuration, "-o", outputfolder, "--runtime", runtime], csproj_file_folder,print_live_output=self.get_verbosity()==LogLevel.Debug)
231
263
  if copy_license_file_to_target_folder:
232
264
  license_file = os.path.join(repository_folder, "License.txt")
@@ -249,26 +281,24 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
249
281
  sarif_target_file = os.path.join(sarif_folder_target, sarif_filename)
250
282
  GeneralUtilities.ensure_file_does_not_exist(sarif_target_file)
251
283
  shutil.copyfile(sarif_source_file, sarif_target_file)
252
- # The lock-file of this runtime becomes a part of the build-result: it states which version of which package
253
- # the build actually used, which is what makes it possible to reproduce a build later or to check an
254
- # artifact against a vulnerability afterwards. The working-copy keeps its own lock-file, so this is a copy
255
- # and not a move.
256
- # It is copied into a folder per project, because the name of the file only contains the runtime while a
257
- # codeunit builds more than one project (itself and its test-project) for the same runtime, so a flat folder
258
- # would let the second project overwrite the file of the first one. The name of the file itself stays
259
- # unchanged, because it is the name nuget expects and a consumer of the artifact reads the runtime from it.
260
- lock_file = os.path.join(csproj_file_folder, self.__get_lock_file_name(runtime))
261
- if os.path.isfile(lock_file):
262
- lock_file_folder_target = os.path.join(codeunit_folder, "Other", "Artifacts", "PackagesLock", csproj_file_name_without_extension)
263
- GeneralUtilities.ensure_directory_exists(lock_file_folder_target)
264
- lock_file_target = os.path.join(lock_file_folder_target, os.path.basename(lock_file))
265
- GeneralUtilities.ensure_file_does_not_exist(lock_file_target)
266
- shutil.copyfile(lock_file, lock_file_target)
267
- else:
268
- # The restore which ran above creates the file whenever the project demands one (see
269
- # __get_lock_file_arguments), so a missing file means the project does not set
270
- # RestorePackagesWithLockFile - and then the build-result does not state which versions it used.
271
- self._protected_sc.log.log(f"The lock-file \"{lock_file}\" does not exist, so the build-result of \"{csproj_file_name_without_extension}\" does not contain the versions which were used for the runtime \"{runtime}\".", LogLevel.Warning)
284
+ # The lock-file becomes a part of the build-result: it states which version of which package the build actually used,
285
+ # which is what makes it possible to reproduce a build later or to check an artifact against a vulnerability
286
+ # afterwards. It covers every runtime which was built, so it is copied once and not per runtime. The working-copy
287
+ # keeps its own lock-file, so this is a copy and not a move.
288
+ # The target is a folder per project, because every project of the codeunit has a lock-file of the same name and a
289
+ # flat folder would let the second project overwrite the file of the first one.
290
+ lock_file = os.path.join(csproj_file_folder, self.__get_lock_file_name())
291
+ if os.path.isfile(lock_file):
292
+ lock_file_folder_target = os.path.join(codeunit_folder, "Other", "Artifacts", "PackagesLock", csproj_file_name_without_extension)
293
+ GeneralUtilities.ensure_directory_exists(lock_file_folder_target)
294
+ lock_file_target = os.path.join(lock_file_folder_target, os.path.basename(lock_file))
295
+ GeneralUtilities.ensure_file_does_not_exist(lock_file_target)
296
+ shutil.copyfile(lock_file, lock_file_target)
297
+ else:
298
+ # The restore which ran above creates the file whenever the project demands one (see __get_lock_file_arguments),
299
+ # so a missing file means the project does not set RestorePackagesWithLockFile - and then the build-result does
300
+ # not state which versions it used.
301
+ self._protected_sc.log.log(f"The lock-file \"{lock_file}\" does not exist, so the build-result of \"{csproj_file_name_without_extension}\" does not contain the versions which were used.", LogLevel.Warning)
272
302
 
273
303
  @GeneralUtilities.check_arguments
274
304
  def standardized_tasks_build_for_dotnet_project(self,runtimes:list[str]) -> None:
@@ -356,8 +386,6 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
356
386
  bomfile_folder = "Other/Artifacts/BOM"
357
387
  # "-dpr" keeps CycloneDX from restoring the project itself. The SBOM is generated directly after the project and its
358
388
  # test-project were built, so the dependencies are restored and the assets-file CycloneDX reads is up-to-date already.
359
- # Its restore would also not be able to name the lock-file of the runtime the build used, so it would write one under
360
- # the default-name (see __get_arguments_which_prevent_writing_a_lock_file).
361
389
  self._protected_sc.run_program_argsasarray("dotnet", ["CycloneDX", f"{codeunit_name}/{codeunit_name}.csproj", "-o", bomfile_folder, "-dpr"], codeunit_folder)
362
390
  codeunitversion = self.tfcps_Tools_General.get_version_of_codeunit(os.path.join(codeunit_folder, f"{codeunit_name}.codeunit.xml"))
363
391
  target = f"{codeunit_folder}/{bomfile_folder}/{codeunit_name}.{codeunitversion}.sbom.xml"
@@ -390,7 +418,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
390
418
  # begin with a drive-letter anymore) and resolves against the working-directory, so it writes to a path
391
419
  # which contains a quote in the middle. On Linux that only creates a strangely named folder, on Windows a
392
420
  # quote is not allowed in a path and the msbuild-task GenerateDepsFile fails with an IOException.
393
- run_result = self._protected_sc.run_program_argsasarray("dotnet", ["build", sln_file, "-nologo", "-v", "minimal", "-o", temp_output_folder]+self.__get_arguments_which_prevent_writing_a_lock_file(), temp_output_folder, throw_exception_if_exitcode_is_not_zero=False, env_vars={"DOTNET_CLI_UI_LANGUAGE": "en-US", "MSBUILDDISABLENODEREUSE": "1"})
421
+ run_result = self._protected_sc.run_program_argsasarray("dotnet", ["build", sln_file, "-nologo", "-v", "minimal", "-o", temp_output_folder], temp_output_folder, throw_exception_if_exitcode_is_not_zero=False, env_vars={"DOTNET_CLI_UI_LANGUAGE": "en-US", "MSBUILDDISABLENODEREUSE": "1"})
394
422
  finally:
395
423
  GeneralUtilities.ensure_directory_does_not_exist(temp_output_folder)
396
424
  diagnostics: list[tuple[LogLevel, str, str | None, int | None]] = []
@@ -527,6 +555,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
527
555
  regex = f"""^<Project Sdk=\\"Microsoft\\.NET\\.Sdk\\">
528
556
  <PropertyGroup>
529
557
  <TargetFramework>([^<]+)<\\/TargetFramework>
558
+ <RuntimeIdentifiers>([^<]+)<\\/RuntimeIdentifiers>
530
559
  <Authors>([^<]+)<\\/Authors>
531
560
  <Version>{codeunit_version_regex}<\\/Version>
532
561
  <AssemblyVersion>{codeunit_version_regex}<\\/AssemblyVersion>
@@ -593,6 +622,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
593
622
  regex = f"""^<Project Sdk=\\"Microsoft\\.NET\\.Sdk\\">
594
623
  <PropertyGroup>
595
624
  <TargetFramework>([^<]+)<\\/TargetFramework>
625
+ <RuntimeIdentifiers>([^<]+)<\\/RuntimeIdentifiers>
596
626
  <Authors>([^<]+)<\\/Authors>
597
627
  <Version>{codeunit_version_regex}<\\/Version>
598
628
  <AssemblyVersion>{codeunit_version_regex}<\\/AssemblyVersion>
@@ -685,11 +715,10 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
685
715
  def _protected_restore_projects_for_the_metadata_of_docfx(self) -> None:
686
716
  """Restores the projects of this codeunit, so that docfx can read them without restoring them itself.
687
717
 
688
- The reference is generated from the sourcecode and not for one runtime, so this restore knows no runtime either and
689
- its lock-file is pointed at the throwaway-path like the one of every other operation of that kind (see
690
- __get_arguments_which_prevent_writing_a_lock_file). The restore is done here and not left to docfx, because the
691
- reference of a codeunit can also be generated on its own, without a build before it."""
692
- self._protected_sc.run_program_argsasarray("dotnet", ["restore"]+self.__get_arguments_which_prevent_writing_a_lock_file(), self.get_codeunit_folder(), print_live_output=self.get_verbosity() == LogLevel.Debug)
718
+ Like every restore of a codeunit this one names no runtime, so it writes the same lock-file the build reads and there
719
+ is nothing to keep it away from. The restore is done here and not left to docfx, because docfx is called with
720
+ "--noRestore" and because the reference of a codeunit can also be generated on its own, without a build before it."""
721
+ self._protected_sc.run_program_argsasarray("dotnet", ["restore"], self.get_codeunit_folder(), print_live_output=self.get_verbosity() == LogLevel.Debug)
693
722
 
694
723
  @GeneralUtilities.check_arguments
695
724
  def generate_reference(self, generate_class_reference:bool=False) -> None:
@@ -725,7 +754,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
725
754
  GeneralUtilities.ensure_file_does_not_exist(target_file)
726
755
 
727
756
  sln_file = os.path.join(codeunit_folder, f"{codeunit_name}.sln")
728
- args: list[str] = ["test", sln_file, "-c", dotnet_build_configuration, "-o", temp_folder]+self.__get_arguments_which_prevent_writing_a_lock_file()
757
+ args: list[str] = ["test", sln_file, "-c", dotnet_build_configuration, "-o", temp_folder]
729
758
  runsettings_path = os.path.join(codeunit_folder, runsettings_file)
730
759
  if os.path.isfile(runsettings_path):
731
760
  args += ["--settings", runsettings_path]
@@ -808,6 +837,16 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
808
837
  def get_available_versions(self,dependencyname:str)->list[str]:
809
838
  return []#TODO
810
839
 
840
+ @GeneralUtilities.check_arguments
841
+ def update_dependencies_with_specific_echolon(self, echolon: VersionEcholon) -> None:
842
+ """Updates the dependencies of this codeunit and confirms the result in its lock-files.
843
+
844
+ The update changes the versions the project-files ask for, and the lock-files still state the versions which were
845
+ resolved before. Writing them again is part of the update: without it the next build fails with NU1004, and the
846
+ state of the dependencies of the codeunit would be spread over two places which do not agree."""
847
+ super().update_dependencies_with_specific_echolon(echolon)
848
+ self.tfcps_Tools_General.update_lock_files_of_dotnet_codeunit(self.get_codeunit_folder())
849
+
811
850
  def set_dependency_version(self,name:str,new_version:str)->None:
812
851
  raise ValueError(f"Operation is not implemented.")
813
852
  #csproj_file:str=os.path.join(self.get_codeunit_folder(), self.get_codeunit_name(), self.get_codeunit_name() + ".csproj")
@@ -1877,19 +1877,21 @@ class TFCPS_Tools_General:
1877
1877
  self.__sc.run_program_argsasarray("gh", ["release", "create", f"v{projectversion}", "--repo", github_repo, "--notes-file", changelog_file, "--title", f"Release v{projectversion}"]+artifact_files)
1878
1878
 
1879
1879
  @GeneralUtilities.check_arguments
1880
- def get_throwaway_lock_file(self, codeunit_name: str) -> str:
1881
- """Returns the path of a lock-file whose content is not used by anybody.
1882
-
1883
- Every dotnet-operation of a codeunit restores, and a project which demands a lock-file (see the property
1884
- RestorePackagesWithLockFile) makes each of those restores write one. Only the restore of the build knows which
1885
- runtime it restores for and therefore which lock-file belongs to the result; every other operation would write
1886
- one under the default-name next to it, which is not validated against anything and only looks like the relevant
1887
- pinning. Those operations are therefore pointed at this path instead.
1888
- The path is not inside the repository, so the operations leave nothing behind there, and it contains the name of
1889
- the codeunit, so two codeunits which are built at the same time do not write to the same file."""
1890
- folder = os.path.join(GeneralUtilities.get_temp_folder(), "ScriptCollection", "ThrowawayLockFiles", codeunit_name)
1891
- GeneralUtilities.ensure_directory_exists(folder)
1892
- return os.path.join(folder, "packages.lock.json")
1880
+ def update_lock_files_of_dotnet_codeunit(self, codeunit_folder: str) -> None:
1881
+ """Restores the projects of the given dotnet-codeunit and writes what was resolved into their lock-files.
1882
+
1883
+ This is how a changed dependency is confirmed: the build restores in locked mode, which resolves exactly what the
1884
+ lock-files state and fails with NU1004 as soon as the project asks for something else. A dependency which was
1885
+ changed on purpose therefore needs this - it says "this is the new state" - and the changed lock-files belong to
1886
+ the commit of that change.
1887
+ No runtime is named, so the restore resolves the runtimes which the projects state and writes one lock-file per
1888
+ project which covers all of them."""
1889
+ codeunit_name: str = os.path.basename(codeunit_folder)
1890
+ sln_file: str = os.path.join(codeunit_folder, f"{codeunit_name}.sln")
1891
+ if not os.path.isfile(sln_file):
1892
+ raise ValueError(f"The codeunit-folder \"{codeunit_folder}\" does not contain the solution \"{codeunit_name}.sln\", so it is no dotnet-codeunit whose lock-files could be updated.")
1893
+ self.__sc.log.log(f"Update the lock-files of codeunit \"{codeunit_name}\"...")
1894
+ self.__sc.run_program_argsasarray("dotnet", ["restore", sln_file], codeunit_folder)
1893
1895
 
1894
1896
  @GeneralUtilities.check_arguments
1895
1897
  def get_dependency_version_in_resources_folder(self, resources_folder:str, dependency_name: str) ->str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.4.10
3
+ Version: 4.4.12
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Author-email: Marius Göcke <marius.goecke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
@@ -1,6 +1,6 @@
1
1
  ScriptCollection/AnionBuildPlatform.py,sha256=LF9b4f4iqgsjgXZjS0RHiEBw73tQANfu0O1dYGWNjy8,11948
2
2
  ScriptCollection/CertificateUpdater.py,sha256=bD0VhKQsD2cNRTG1kzMkhgpd0BZw7igbG30goKw5p1A,9749
3
- ScriptCollection/Executables.py,sha256=Gl4sT5XMqdT9GmUSX4eGoakURwCS0CxufavdQsRqxjM,72517
3
+ ScriptCollection/Executables.py,sha256=jU4TPpi3psAd1gsMVAGCrw6Wyv7MdX1spBh9Grk0gbA,74303
4
4
  ScriptCollection/GeneralUtilities.py,sha256=JeUZM4uHO85RAbx-MIYRXAVmklTw7UycVnrSxbXFROI,71417
5
5
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
6
6
  ScriptCollection/ProcessesRunner.py,sha256=Va9O-ohWoRfe4pO2gPBzc940gkM5BpP4Txcu1CmLOvg,1494
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=ot9Ib-plQ8wejR9M2XXfnx6GR-va9k8SH1gAC5kjaJ0,5123
11
11
  ScriptCollection/SCLog.py,sha256=Fjf8Pdi63cXHGMxL_aI6A0dwGm7QIfrv3czjvpSUlaM,4705
12
- ScriptCollection/ScriptCollectionCore.py,sha256=kfI9PrinFNNJ5e0vy7RywhwXm9_9mU0g4j9AyFsVTyE,261811
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=QyUfpkajP2hQf2SlmpP06aQAB4i2Wu3j0FbRW8DdGYU,261811
13
13
  ScriptCollection/TestKind.py,sha256=EBTLR8yBz5VmWA2NZIpDTbQNg6tkfv_kAsIzEJ--mCI,1756
14
14
  ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
15
15
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -47,7 +47,7 @@ ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=oYEhz5ZWMnbu97_CcYEqdDxakUF
47
47
  ScriptCollection/TFCPS/TFCPS_OCIImageSecretScan.py,sha256=rhw0glr4gZ5enG9faOD51xE4MMK1cIdNjUdaswiMsrY,14622
48
48
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=XLVsFTA1jvfDbZ7wYJgIdEByZhF_bYVbA5jkisuvK4k,2322
49
49
  ScriptCollection/TFCPS/TFCPS_RemoteBuild.py,sha256=Z8Gw-j5I7VPafHEsVeQJ2gTTKVLAnnhwZhY8IVTi2Qk,11867
50
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=ujl2kltznTMQCibnltTuG51kmFChzOtd2M2QLXY5wEE,164189
50
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=XC2KXHiF5gNptyinqyWaK2DeP0li-hD4f-yEB2sktVQ,164339
51
51
  ScriptCollection/TFCPS/TFCPS_VisualRegressionTests.py,sha256=6_63udxHnPlu_TMk_ftLZTnzriJO8MCxVCVAsweZqHs,37073
52
52
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=919mNfzVRurTJhWi8WV0oEAFoH-yd4a6m2Rbxcf2oZ4,19927
@@ -55,7 +55,7 @@ ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
55
55
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py,sha256=bT6Gd5pQpZCw4OQz6HWkPCSn5z__eUUEisABLDSxd0o,200
56
56
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=QyjOfMY22JWCvKjMelHiDWbJiWqotOfebpJpgDUaoO4,237
57
57
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
58
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=A4eIIJGDrbXZSYH80Ooudma_YQHQvf7coYBMvOA4r70,59462
58
+ ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=GCFzDNAnmm40EeqOYgD_EeuEwDY58ujwJ1-Zn_naamc,61797
59
59
  ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=cAE_OFJBU0M3L2Ov5PUUMH7aOVVzKtnKlFoXSw43fng,8759
61
61
  ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -71,8 +71,8 @@ ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=yyjWPMHQjPLkML
71
71
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  ScriptCollection/TFCPS/TypeScript/TFCPS_CodeUnitSpecific_TypeScript.py,sha256=5z990qyO5durX07xRWRwju1hl6wpjQAy2f-yRwJ-7s0,11856
73
73
  ScriptCollection/TFCPS/TypeScript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- scriptcollection-4.4.10.dist-info/METADATA,sha256=cYHDkvcc2oaJG1PWoDUbRS6gggPDoUNW9jv65NRm5eM,7648
75
- scriptcollection-4.4.10.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
- scriptcollection-4.4.10.dist-info/entry_points.txt,sha256=Aj6CHuJxASMe52fK_O6-bNJ_uhxcDb-AgRxFOeTojyE,6069
77
- scriptcollection-4.4.10.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
- scriptcollection-4.4.10.dist-info/RECORD,,
74
+ scriptcollection-4.4.12.dist-info/METADATA,sha256=JVKXuIC0_F4BSy16DNacDFqmMlY-mywadrAeDb-yqU8,7648
75
+ scriptcollection-4.4.12.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
+ scriptcollection-4.4.12.dist-info/entry_points.txt,sha256=GNma7tN0J59EvK71su-G1w22RnZ05bXcPrELyLx3AL0,6151
77
+ scriptcollection-4.4.12.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
+ scriptcollection-4.4.12.dist-info/RECORD,,
@@ -79,6 +79,7 @@ scsyncxlffiles = ScriptCollection.Executables:SyncXlfFiles
79
79
  scupdatedependencies = ScriptCollection.Executables:UpdateDependencies
80
80
  scupdatedependenciesc = ScriptCollection.Executables:UpdateDependenciesC
81
81
  scupdateimagesindockercomposefile = ScriptCollection.Executables:UpdateImagesInDockerComposeFile
82
+ scupdatelockfiles = ScriptCollection.Executables:UpdateLockFilesOfDotNetCodeUnits
82
83
  scupdatenugetpackagesincsharpproject = ScriptCollection.Executables:UpdateNugetpackagesInCsharpProject
83
84
  scupdatetimestampinfile = ScriptCollection.Executables:UpdateTimestampInFile
84
85
  scuploadfile = ScriptCollection.Executables:UploadFile