makit 0.0.176 → 0.0.177
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.
- checksums.yaml +4 -4
- data/lib/makit/msbuild.rb +45 -0
- data/lib/makit/nuget.rb +34 -0
- data/lib/makit/version.rb +1 -1
- data/lib/makit.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc386dde3db0fe6432b9b85b3b00dc999c20196e3efb93fd9d29d18db82f8350
|
|
4
|
+
data.tar.gz: c1714543dc6bdfad90b7d27f8216a8d16e1e036f3d6d8caba995e5f3de904379
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34345e6eb386707bf6e77c3cffeccb9570b374633b9a2a4731215a6a7dfb796d9dbf75b77b291563bbc09f569a4eafdfaa04cadf7ca89313bb00e2f77c46d14d
|
|
7
|
+
data.tar.gz: 7d77300973c442e66266990be6e5e80ba345b8ea72480e8f76dd63784e40a9a7121bdb30a62ae820b2e44c0fa38f37f65bcfea5ba470037063fa6b00189c0822
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "open3"
|
|
4
|
+
|
|
5
|
+
module Makit
|
|
6
|
+
# Helpers for locating and invoking MSBuild (Windows).
|
|
7
|
+
module Msbuild
|
|
8
|
+
# Locates MSBuild executable: vswhere when available, then common VS 2022 paths, else "msbuild" on PATH.
|
|
9
|
+
#
|
|
10
|
+
# @return [String] Path to MSBuild.exe or "msbuild" as fallback
|
|
11
|
+
def self.find_msbuild
|
|
12
|
+
return find_msbuild_windows if Makit::Environment.is_windows?
|
|
13
|
+
|
|
14
|
+
"msbuild"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @return [String]
|
|
18
|
+
def self.find_msbuild_windows
|
|
19
|
+
vswhere_path = nil
|
|
20
|
+
if ENV["ProgramFiles(x86)"]
|
|
21
|
+
p = File.join(ENV["ProgramFiles(x86)"], "Microsoft Visual Studio", "Installer", "vswhere.exe")
|
|
22
|
+
vswhere_path = p if File.exist?(p)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
if vswhere_path
|
|
26
|
+
stdout, _stderr, status = Open3.capture3(
|
|
27
|
+
vswhere_path, "-latest", "-requires", "Microsoft.Component.MSBuild",
|
|
28
|
+
"-find", "MSBuild\\**\\Bin\\MSBuild.exe"
|
|
29
|
+
)
|
|
30
|
+
if status.success? && !stdout.strip.empty?
|
|
31
|
+
path = stdout.strip.lines.first&.strip
|
|
32
|
+
return path if path && File.exist?(path)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
%w[Community Professional Enterprise BuildTools].each do |edition|
|
|
37
|
+
p = "C:\\Program Files\\Microsoft Visual Studio\\2022\\#{edition}\\MSBuild\\Current\\Bin\\MSBuild.exe"
|
|
38
|
+
return p if File.exist?(p)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
"msbuild"
|
|
42
|
+
end
|
|
43
|
+
private_class_method :find_msbuild_windows
|
|
44
|
+
end
|
|
45
|
+
end
|
data/lib/makit/nuget.rb
CHANGED
|
@@ -318,6 +318,9 @@ module Makit
|
|
|
318
318
|
return false
|
|
319
319
|
end
|
|
320
320
|
|
|
321
|
+
#config_paths = existing_nuget_config_paths
|
|
322
|
+
#content_before = config_paths.to_h { |p| [p, File.read(p)] }
|
|
323
|
+
|
|
321
324
|
args = ["dotnet", "nuget", "add", "source", url, "--name", name]
|
|
322
325
|
args << "--username" << username if username
|
|
323
326
|
args << "--password" << password if password
|
|
@@ -325,6 +328,18 @@ module Makit
|
|
|
325
328
|
|
|
326
329
|
stdout, stderr, status = Open3.capture3(*args)
|
|
327
330
|
|
|
331
|
+
#if config_paths.any?
|
|
332
|
+
# config_paths.each do |path|
|
|
333
|
+
# next unless content_before.key?(path)
|
|
334
|
+
# content_after = File.read(path)
|
|
335
|
+
# if content_after != content_before[path]
|
|
336
|
+
# Makit::Logging.default_logger.warn(
|
|
337
|
+
# "WARNING: NuGet config file was modified by add_source. Expected content to remain unchanged: #{path}"
|
|
338
|
+
# )
|
|
339
|
+
# end
|
|
340
|
+
# end
|
|
341
|
+
#end
|
|
342
|
+
|
|
328
343
|
if status.success?
|
|
329
344
|
Makit::Logging.default_logger.info("Added NuGet source '#{name}' (#{url})")
|
|
330
345
|
true
|
|
@@ -334,6 +349,25 @@ module Makit
|
|
|
334
349
|
end
|
|
335
350
|
end
|
|
336
351
|
|
|
352
|
+
# Returns paths to NuGet config files that exist (current directory and user-level).
|
|
353
|
+
# Used to detect if add_source modifies any existing config.
|
|
354
|
+
#
|
|
355
|
+
# @return [Array<String>]
|
|
356
|
+
def self.existing_nuget_config_paths
|
|
357
|
+
candidates = [
|
|
358
|
+
File.join(Dir.pwd, "NuGet.config"),
|
|
359
|
+
File.join(Dir.pwd, "nuget.config")
|
|
360
|
+
]
|
|
361
|
+
if ENV["APPDATA"]
|
|
362
|
+
candidates << File.join(ENV["APPDATA"], "NuGet", "NuGet.Config")
|
|
363
|
+
else
|
|
364
|
+
candidates << File.expand_path(File.join("~", ".nuget", "NuGet", "NuGet.Config"))
|
|
365
|
+
candidates << File.expand_path(File.join("~", ".config", "NuGet", "NuGet.Config"))
|
|
366
|
+
end
|
|
367
|
+
candidates.select { |p| File.file?(p) }.uniq
|
|
368
|
+
end
|
|
369
|
+
private_class_method :existing_nuget_config_paths
|
|
370
|
+
|
|
337
371
|
# Removes a NuGet source
|
|
338
372
|
#
|
|
339
373
|
# @param name [String] The source name to remove
|
data/lib/makit/version.rb
CHANGED
data/lib/makit.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: makit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.177
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lou Parslow
|
|
@@ -342,6 +342,7 @@ files:
|
|
|
342
342
|
- lib/makit/mp/command_request.mp.rb
|
|
343
343
|
- lib/makit/mp/project_mp.rb
|
|
344
344
|
- lib/makit/mp/string_mp.rb
|
|
345
|
+
- lib/makit/msbuild.rb
|
|
345
346
|
- lib/makit/nuget.rb
|
|
346
347
|
- lib/makit/nuget_cache.rb
|
|
347
348
|
- lib/makit/podman/podman.rb
|