2014-05-06 04:18:06 -07:00
|
|
|
CONFIG = ENV['CONFIG'] || 'Debug'
|
2014-05-06 00:35:07 -07:00
|
|
|
|
2014-05-06 04:18:06 -07:00
|
|
|
COVERAGE_DIR = 'Coverage'
|
2014-05-06 05:11:51 -07:00
|
|
|
COVERAGE_FILE = File.join(COVERAGE_DIR, 'coverage.xml')
|
2014-05-06 04:18:06 -07:00
|
|
|
|
2015-06-02 11:47:14 -07:00
|
|
|
GITLINK_REMOTE = 'https://github.com/canton7/stylet'
|
|
|
|
NUSPEC = 'NuGet/Stylet.nuspec'
|
2015-12-21 09:37:54 -08:00
|
|
|
NUSPEC_START = 'NuGet/Stylet.start.nuspec'
|
2015-06-02 11:47:14 -07:00
|
|
|
|
2015-09-08 14:10:11 -07:00
|
|
|
ASSEMBLY_INFO = 'Stylet/Properties/AssemblyInfo.cs'
|
|
|
|
|
2015-09-25 07:28:11 -07:00
|
|
|
CSPROJ = 'Stylet/Stylet.csproj'
|
2019-09-24 06:51:33 -07:00
|
|
|
TEMPLATES_CSPROJ = 'StyletTemplates/StyletTemplates.csproj'
|
2019-09-22 07:36:00 -07:00
|
|
|
UNIT_TESTS = 'StyletUnitTests/StyletUnitTests.csproj'
|
2015-09-25 07:28:11 -07:00
|
|
|
|
2019-09-24 06:51:33 -07:00
|
|
|
TEMPLATES_DIR = 'StyletTemplates/templates'
|
|
|
|
|
2014-05-06 10:30:04 -07:00
|
|
|
directory COVERAGE_DIR
|
|
|
|
|
2019-09-22 07:36:00 -07:00
|
|
|
desc "Build the project using the current CONFIG (or Debug)"
|
2015-09-25 07:28:11 -07:00
|
|
|
task :build do
|
2021-01-21 12:05:01 -08:00
|
|
|
sh 'dotnet', 'build', '-c', CONFIG, CSPROJ
|
2014-05-06 00:35:07 -07:00
|
|
|
end
|
|
|
|
|
2014-05-06 05:11:51 -07:00
|
|
|
desc "Run unit tests using the current CONFIG (or Debug)"
|
2019-09-22 07:36:00 -07:00
|
|
|
task :test do
|
2021-01-21 12:05:01 -08:00
|
|
|
sh 'dotnet', 'test', '-c', CONFIG, UNIT_TESTS
|
2014-05-09 03:26:26 -07:00
|
|
|
end
|
|
|
|
|
2015-06-02 11:47:14 -07:00
|
|
|
desc "Create NuGet package"
|
|
|
|
task :package do
|
2019-09-22 09:00:53 -07:00
|
|
|
# Not sure why these have to be this way around, but they do
|
2021-01-21 12:05:01 -08:00
|
|
|
sh 'dotnet', 'pack', '--no-build', '-c', CONFIG, CSPROJ, "-p:NuSpecFile=../#{NUSPEC_START}"
|
|
|
|
sh 'dotnet', 'pack', '--no-build', '-c', CONFIG, CSPROJ, '-p:IncludeSymbols=true'
|
|
|
|
sh 'dotnet', 'pack', '-c', CONFIG, TEMPLATES_CSPROJ
|
2015-06-02 11:47:14 -07:00
|
|
|
end
|
|
|
|
|
2015-09-08 14:10:11 -07:00
|
|
|
desc "Bump version number"
|
|
|
|
task :version, [:version] do |t, args|
|
|
|
|
parts = args[:version].split('.')
|
|
|
|
parts << '0' if parts.length == 3
|
|
|
|
version = parts.join('.')
|
|
|
|
|
2019-09-22 08:13:19 -07:00
|
|
|
content = IO.read(CSPROJ)
|
|
|
|
content[/<VersionPrefix>(.+?)<\/VersionPrefix>/, 1] = version
|
|
|
|
File.open(CSPROJ, 'w'){ |f| f.write(content) }
|
2015-12-21 09:37:54 -08:00
|
|
|
|
2019-09-24 06:51:33 -07:00
|
|
|
content = IO.read(TEMPLATES_CSPROJ)
|
|
|
|
content[/<VersionPrefix>(.+?)<\/VersionPrefix>/, 1] = version
|
|
|
|
File.open(TEMPLATES_CSPROJ, 'w'){ |f| f.write(content) }
|
|
|
|
|
2015-12-21 09:37:54 -08:00
|
|
|
content = IO.read(NUSPEC_START)
|
|
|
|
content[/<version>(.+?)<\/version>/, 1] = args[:version]
|
|
|
|
content[%r{<dependency id="Stylet" version="\[(.+?)\]"/>}, 1] = args[:version]
|
|
|
|
File.open(NUSPEC_START, 'w'){ |f| f.write(content) }
|
2019-09-24 06:51:33 -07:00
|
|
|
|
|
|
|
Dir[File.join(TEMPLATES_DIR, '**/*.csproj')].each do |csproj|
|
|
|
|
content = IO.read(csproj)
|
|
|
|
content[/<PackageReference Include="Stylet" Version="(.+?)" \/>/, 1] = version
|
|
|
|
File.open(csproj, 'w'){ |f| f.write(content) }
|
|
|
|
end
|
2015-09-08 14:10:11 -07:00
|
|
|
end
|
|
|
|
|
2014-08-27 11:34:51 -07:00
|
|
|
desc "Extract StyletIoC as a standalone file"
|
|
|
|
task :"extract-stylet-ioc" do
|
2014-09-11 05:39:47 -07:00
|
|
|
filenames = Dir['Stylet/StyletIoC/**/*.cs']
|
2014-08-27 11:34:51 -07:00
|
|
|
usings = Set.new
|
2014-09-11 05:39:47 -07:00
|
|
|
files = []
|
2014-08-27 11:34:51 -07:00
|
|
|
|
2014-09-11 05:39:47 -07:00
|
|
|
filenames.each do |file|
|
2014-08-27 11:34:51 -07:00
|
|
|
contents = File.read(file)
|
|
|
|
file_usings = contents.scan(/using .*?;$/)
|
|
|
|
usings.merge(file_usings)
|
|
|
|
|
2014-09-11 05:39:47 -07:00
|
|
|
matches = contents.match(/namespace (.+?)\n{\n(.+)}.*/m)
|
|
|
|
namespace, file_contents = matches.captures
|
|
|
|
|
|
|
|
files << {
|
|
|
|
:from => file,
|
|
|
|
:contents => file_contents,
|
|
|
|
:namespace => namespace
|
|
|
|
}
|
|
|
|
# merged_contents << " // Originally from #{file}\n\n" << file_contents << "\n"
|
2014-08-27 11:34:51 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
File.open('StyletIoC.cs', 'w') do |outf|
|
2014-09-12 06:04:46 -07:00
|
|
|
outf.write(usings.to_a.join("\n"))
|
2014-08-27 11:34:51 -07:00
|
|
|
|
2014-09-11 05:39:47 -07:00
|
|
|
outf.puts
|
2014-08-27 11:34:51 -07:00
|
|
|
|
2014-09-11 05:39:47 -07:00
|
|
|
files.group_by{ |x| x[:namespace ] }.each do |namespace, ns_files|
|
|
|
|
outf.puts("\nnamespace #{namespace}")
|
|
|
|
outf.puts("{")
|
|
|
|
|
|
|
|
ns_files.each do |file|
|
|
|
|
outf.puts("\n // Originally from #{file[:from]}\n\n")
|
|
|
|
outf.puts(file[:contents])
|
|
|
|
end
|
|
|
|
|
|
|
|
outf.puts("}\n")
|
|
|
|
end
|
2014-08-27 11:34:51 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
# puts merged_contents
|
2014-05-09 03:26:26 -07:00
|
|
|
|
2014-09-11 05:39:47 -07:00
|
|
|
end
|
2015-09-08 14:10:11 -07:00
|
|
|
|