mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Adding SRGen to build scripts (#45)
* Adding SRGen to build scripts Adding support for sr.strings files. sr.strings files can be converted into .resx and designer cs files by running the SRGen Cake target Adding a new target to Cake script to run SRGen. SRGen is pulled down as a nuget package for Cake and executes from the .tools folder. Adding Cake temp environment to the gitignore Adding the cake scripts to the sqltoolsservice solution file * Fixes from pull request comments * Fix as per @llali * Actual changes as per @llali * removing platform type from netcore dependency
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -276,3 +276,7 @@ Session.vim
|
|||||||
|
|
||||||
# Visual Studio Code
|
# Visual Studio Code
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
# Stuff from cake
|
||||||
|
/artifacts/
|
||||||
|
/.tools/
|
||||||
153
build.cake
153
build.cake
@@ -81,7 +81,8 @@ Task("Cleanup")
|
|||||||
/// Pre-build setup tasks.
|
/// Pre-build setup tasks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task("Setup")
|
Task("Setup")
|
||||||
.IsDependentOn("BuildEnvironment")
|
.IsDependentOn("InstallDotnet")
|
||||||
|
.IsDependentOn("InstallXUnit")
|
||||||
.IsDependentOn("PopulateRuntimes")
|
.IsDependentOn("PopulateRuntimes")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
@@ -92,7 +93,6 @@ Task("Setup")
|
|||||||
/// Use default RID (+ win7-x86 on Windows) for now.
|
/// Use default RID (+ win7-x86 on Windows) for now.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task("PopulateRuntimes")
|
Task("PopulateRuntimes")
|
||||||
.IsDependentOn("BuildEnvironment")
|
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
buildPlan.Rids = new string[]
|
buildPlan.Rids = new string[]
|
||||||
@@ -112,43 +112,65 @@ Task("PopulateRuntimes")
|
|||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Install/update build environment.
|
/// Install dotnet if it isn't already installed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task("BuildEnvironment")
|
Task("InstallDotnet")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
var installScript = $"dotnet-install.{shellExtension}";
|
// Determine if `dotnet` is installed
|
||||||
System.IO.Directory.CreateDirectory(dotnetFolder);
|
var dotnetInstalled = true;
|
||||||
var scriptPath = System.IO.Path.Combine(dotnetFolder, installScript);
|
try
|
||||||
using (WebClient client = new WebClient())
|
{
|
||||||
{
|
Run(dotnetcli, "--info");
|
||||||
client.DownloadFile($"{buildPlan.DotNetInstallScriptURL}/{installScript}", scriptPath);
|
Information("dotnet is already installed, will skip download/install");
|
||||||
}
|
}
|
||||||
if (!IsRunningOnWindows())
|
catch(Win32Exception)
|
||||||
{
|
{
|
||||||
Run("chmod", $"+x '{scriptPath}'");
|
// If we get this exception, dotnet isn't installed
|
||||||
}
|
dotnetInstalled = false;
|
||||||
var installArgs = $"-Channel {buildPlan.DotNetChannel}";
|
}
|
||||||
if (!String.IsNullOrEmpty(buildPlan.DotNetVersion))
|
|
||||||
{
|
|
||||||
installArgs = $"{installArgs} -Version {buildPlan.DotNetVersion}";
|
|
||||||
}
|
|
||||||
if (!buildPlan.UseSystemDotNetPath)
|
|
||||||
{
|
|
||||||
installArgs = $"{installArgs} -InstallDir {dotnetFolder}";
|
|
||||||
}
|
|
||||||
Run(shell, $"{shellArgument} {scriptPath} {installArgs}");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Run(dotnetcli, "--info");
|
|
||||||
}
|
|
||||||
catch (Win32Exception)
|
|
||||||
{
|
|
||||||
throw new Exception(".NET CLI binary cannot be found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
System.IO.Directory.CreateDirectory(toolsFolder);
|
// Install dotnet if it isn't already installed
|
||||||
|
if (!dotnetInstalled)
|
||||||
|
{
|
||||||
|
var installScript = $"dotnet-install.{shellExtension}";
|
||||||
|
System.IO.Directory.CreateDirectory(dotnetFolder);
|
||||||
|
var scriptPath = System.IO.Path.Combine(dotnetFolder, installScript);
|
||||||
|
using (WebClient client = new WebClient())
|
||||||
|
{
|
||||||
|
client.DownloadFile($"{buildPlan.DotNetInstallScriptURL}/{installScript}", scriptPath);
|
||||||
|
}
|
||||||
|
if (!IsRunningOnWindows())
|
||||||
|
{
|
||||||
|
Run("chmod", $"+x '{scriptPath}'");
|
||||||
|
}
|
||||||
|
var installArgs = $"-Channel {buildPlan.DotNetChannel}";
|
||||||
|
if (!String.IsNullOrEmpty(buildPlan.DotNetVersion))
|
||||||
|
{
|
||||||
|
installArgs = $"{installArgs} -Version {buildPlan.DotNetVersion}";
|
||||||
|
}
|
||||||
|
if (!buildPlan.UseSystemDotNetPath)
|
||||||
|
{
|
||||||
|
installArgs = $"{installArgs} -InstallDir {dotnetFolder}";
|
||||||
|
}
|
||||||
|
Run(shell, $"{shellArgument} {scriptPath} {installArgs}");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Run(dotnetcli, "--info");
|
||||||
|
}
|
||||||
|
catch (Win32Exception)
|
||||||
|
{
|
||||||
|
throw new Exception(".NET CLI failed to be installed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Installs XUnit nuget package
|
||||||
|
Task("InstallXUnit")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
// Install the tools
|
||||||
var nugetPath = Environment.GetEnvironmentVariable("NUGET_EXE");
|
var nugetPath = Environment.GetEnvironmentVariable("NUGET_EXE");
|
||||||
var arguments = $"install xunit.runner.console -ExcludeVersion -NoCache -Prerelease -OutputDirectory \"{toolsFolder}\"";
|
var arguments = $"install xunit.runner.console -ExcludeVersion -NoCache -Prerelease -OutputDirectory \"{toolsFolder}\"";
|
||||||
if (IsRunningOnWindows())
|
if (IsRunningOnWindows())
|
||||||
@@ -208,14 +230,6 @@ Task("TestAll")
|
|||||||
.IsDependentOn("TestCore")
|
.IsDependentOn("TestCore")
|
||||||
.Does(() =>{});
|
.Does(() =>{});
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Run all tests for Travis CI .NET Desktop and .NET Core
|
|
||||||
/// </summary>
|
|
||||||
Task("TravisTestAll")
|
|
||||||
.IsDependentOn("Cleanup")
|
|
||||||
.IsDependentOn("TestAll")
|
|
||||||
.Does(() =>{});
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Run tests for .NET Core (using .NET CLI).
|
/// Run tests for .NET Core (using .NET CLI).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -345,6 +359,7 @@ Task("RestrictToLocalRuntime")
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Task("LocalPublish")
|
Task("LocalPublish")
|
||||||
.IsDependentOn("Restore")
|
.IsDependentOn("Restore")
|
||||||
|
.IsDependentOn("SrGen")
|
||||||
.IsDependentOn("RestrictToLocalRuntime")
|
.IsDependentOn("RestrictToLocalRuntime")
|
||||||
.IsDependentOn("OnlyPublish")
|
.IsDependentOn("OnlyPublish")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
@@ -451,20 +466,6 @@ Task("Local")
|
|||||||
{
|
{
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Build centered around producing the final artifacts for Travis
|
|
||||||
///
|
|
||||||
/// The tests are run as a different task "TestAll"
|
|
||||||
/// </summary>
|
|
||||||
Task("Travis")
|
|
||||||
.IsDependentOn("Cleanup")
|
|
||||||
.IsDependentOn("Restore")
|
|
||||||
.IsDependentOn("AllPublish")
|
|
||||||
// .IsDependentOn("TestPublished")
|
|
||||||
.Does(() =>
|
|
||||||
{
|
|
||||||
});
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the package versions within project.json files.
|
/// Update the package versions within project.json files.
|
||||||
/// Uses depversion.json file as input.
|
/// Uses depversion.json file as input.
|
||||||
@@ -492,6 +493,46 @@ Task("SetPackageVersions")
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executes SRGen to create a resx file and associated designer C# file
|
||||||
|
/// </summary>
|
||||||
|
Task("SRGen")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
var projects = System.IO.Directory.GetFiles(sourceFolder, "project.json", SearchOption.AllDirectories).ToList();
|
||||||
|
foreach(var project in projects) {
|
||||||
|
var projectDir = System.IO.Path.GetDirectoryName(project);
|
||||||
|
var projectName = (new System.IO.DirectoryInfo(projectDir)).Name;
|
||||||
|
var projectStrings = System.IO.Path.Combine(projectDir, "sr.strings");
|
||||||
|
|
||||||
|
if (!System.IO.File.Exists(projectStrings))
|
||||||
|
{
|
||||||
|
Information("Project {0} doesn't contain 'sr.strings' file", projectName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var srgenPath = System.IO.Path.Combine(toolsFolder, "Microsoft.DataTools.SrGen", "lib", "netcoreapp1.0", "srgen.dll");
|
||||||
|
var outputResx = System.IO.Path.Combine(projectDir, "sr.resx");
|
||||||
|
var outputCs = System.IO.Path.Combine(projectDir, "sr.cs");
|
||||||
|
|
||||||
|
// Delete preexisting resx and designer files
|
||||||
|
if (System.IO.File.Exists(outputResx))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(outputResx);
|
||||||
|
}
|
||||||
|
if (System.IO.File.Exists(outputCs))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(outputCs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run SRGen
|
||||||
|
var dotnetArgs = string.Format("{0} -or \"{1}\" -oc \"{2}\" -ns \"{3}\" -an \"{4}\" -cn SR -l CS \"{5}\"",
|
||||||
|
srgenPath, outputResx, outputCs, projectName, projectName, projectStrings);
|
||||||
|
Information("{0}", dotnetArgs);
|
||||||
|
Run(dotnetcli, dotnetArgs);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default Task aliases to Local.
|
/// Default Task aliases to Local.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -106,5 +106,7 @@ if (!(Test-Path $CAKE_EXE)) {
|
|||||||
|
|
||||||
# Start Cake
|
# Start Cake
|
||||||
Write-Host "Running build script..."
|
Write-Host "Running build script..."
|
||||||
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $ScriptArgs"
|
$v = "& `"$CAKE_EXE`" `"$Script`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $ScriptArgs"
|
||||||
|
Write-Host $v
|
||||||
|
Invoke-Expression $v
|
||||||
exit $LASTEXITCODE
|
exit $LASTEXITCODE
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="Cake" version="0.10.1" />
|
<package id="Cake" version="0.10.1" />
|
||||||
<package id="Newtonsoft.Json" version="8.0.3" />
|
<package id="Newtonsoft.Json" version="8.0.3" />
|
||||||
|
<package id="Microsoft.DataTools.SrGen" version="1.0.0" />
|
||||||
</packages>
|
</packages>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ EndProject
|
|||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{32DC973E-9EEA-4694-B1C2-B031167AB945}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{32DC973E-9EEA-4694-B1C2-B031167AB945}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
|
BUILD.md = BUILD.md
|
||||||
global.json = global.json
|
global.json = global.json
|
||||||
nuget.config = nuget.config
|
nuget.config = nuget.config
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
@@ -18,6 +19,25 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.SqlTools.ServiceL
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.SqlTools.ServiceLayer.Test", "test\Microsoft.SqlTools.ServiceLayer.Test\Microsoft.SqlTools.ServiceLayer.Test.xproj", "{2D771D16-9D85-4053-9F79-E2034737DEEF}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.SqlTools.ServiceLayer.Test", "test\Microsoft.SqlTools.ServiceLayer.Test\Microsoft.SqlTools.ServiceLayer.Test.xproj", "{2D771D16-9D85-4053-9F79-E2034737DEEF}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{B7D21727-2926-452B-9610-3ADB0BB6D789}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
scripts\archiving.cake = scripts\archiving.cake
|
||||||
|
scripts\artifacts.cake = scripts\artifacts.cake
|
||||||
|
scripts\cake-bootstrap.ps1 = scripts\cake-bootstrap.ps1
|
||||||
|
scripts\cake-bootstrap.sh = scripts\cake-bootstrap.sh
|
||||||
|
scripts\packages.config = scripts\packages.config
|
||||||
|
scripts\runhelpers.cake = scripts\runhelpers.cake
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F9978D78-78FE-4E92-A7D6-D436B7683EF6}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
build.cake = build.cake
|
||||||
|
build.cmd = build.cmd
|
||||||
|
build.json = build.json
|
||||||
|
build.ps1 = build.ps1
|
||||||
|
build.sh = build.sh
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -39,5 +59,6 @@ Global
|
|||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{0D61DC2B-DA66-441D-B9D0-F76C98F780F9} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
{0D61DC2B-DA66-441D-B9D0-F76C98F780F9} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
||||||
{2D771D16-9D85-4053-9F79-E2034737DEEF} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
|
{2D771D16-9D85-4053-9F79-E2034737DEEF} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
|
||||||
|
{B7D21727-2926-452B-9610-3ADB0BB6D789} = {F9978D78-78FE-4E92-A7D6-D436B7683EF6}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -24,7 +24,12 @@
|
|||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"netcoreapp1.0": {
|
"netcoreapp1.0": {
|
||||||
"imports": "dnxcore50"
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imports": "dnxcore50"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"runtimes": {
|
"runtimes": {
|
||||||
|
|||||||
Reference in New Issue
Block a user