-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrakefile.rb
92 lines (75 loc) · 2.43 KB
/
rakefile.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require_relative 'scripts/coverage'
require_relative 'scripts/utils'
require_relative 'scripts/copy-dependencies'
task :cover do
filter = []
filter << "+[OSPSuite.Core]*"
filter << "+[OSPSuite.Infrastructure]*"
filter << "+[OSPSuite.Presentation]*"
filter << "+[OSPSuite.R]*"
#exclude namespaces that are tested from applications
filter << "-[OSPSuite.Infrastructure.Serialization]OSPSuite.Infrastructure.Serialization.ORM*"
filter << "-[OSPSuite.Presentation]OSPSuite.Presentation.MenuAndBars*"
filter << "-[OSPSuite.Presentation]OSPSuite.Presentation.Presenters.ContextMenus*"
targetProjects = [
"OSPSuite.Core.Tests.csproj",
"OSPSuite.Core.IntegrationTests.csproj",
"OSPSuite.Infrastructure.Tests.csproj",
"OSPSuite.Presentation.Tests.csproj",
"OSPSuite.R.Tests.csproj",
];
Coverage.cover(filter, targetProjects)
end
task :create_local_nuget, [:arg1, :arg2, :arg3] do |t, args|
FileUtils.rm_f Dir.glob("./nuget_repo/*.nupkg")
versionId = "12.0.0-" + generate_code(5)
puts("Your version is " + versionId.red)
system("dotnet", "pack", "-p:PackageVersion="+ versionId, "--configuration", "Debug", "--output", "nuget_repo", "--no-build")
if args.to_hash.values.include? "m"
update_mobi(versionId)
end
if args.to_hash.values.include? "p"
update_pksim(versionId)
end
end
private
def find_token(file, regex)
file_content = str = IO.read(file)
matches = file_content.match(regex)
if(matches.nil?)
return nil
end
return matches[1]
end
def update_mobi(versionId)
puts("updating MoBi")
token = find_token("../MoBi/src/MoBi/MoBi.csproj", /<PackageReference Include="OSPSuite.Core" Version="(.*)"/)
if(token.nil?)
return
end
glob = Dir.glob('../MoBi/**/*.csproj')
glob.each do |file|
Utils.replace_tokens({token => versionId}, file)
end
end
def update_pksim(versionId)
puts("updating PKSim")
token = find_token("../PK-Sim/src/PKSim/PKSim.csproj", /<PackageReference Include="OSPSuite.Core" Version="(.*)"/)
if(token.nil?)
return
end
glob = Dir.glob('../PK-Sim/**/*.csproj')
glob.each do |file|
Utils.replace_tokens({token => versionId}, file)
end
end
def generate_code(number)
charset = Array('A'..'Z') + Array('a'..'z')
Array.new(number) { charset.sample }.join
end
def solution_dir
File.dirname(__FILE__)
end
def tests_dir
File.join(solution_dir, 'tests')
end