Skip to content

feature/netcoreapp2.1 #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: csharp
dotnet: 2.0.0
dotnet: 2.1.300-preview2-008533
env:
global:
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
Expand All @@ -10,11 +10,21 @@ matrix:
include:
- os: linux
dist: trusty
sudo: false
sudo: required
install:
- curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
- sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
- sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
- sudo apt-get update
- sudo apt-get install dotnet-sdk-2.0.3
- os: osx
osx_image: xcode9
sudo: required
script:
- ulimit -n8192
osx_image: xcode9
sudo: required
install:
- ulimit -n8192
- sudo curl -L https://download.microsoft.com/download/5/D/F/5DF4B836-7DFD-4CCF-AC96-101E2A4C7421/dotnet-sdk-2.1.2-osx-x64.pkg -o dotnet-sdk.pkg
- sudo installer -pkg dotnet-sdk.pkg -target /
- dotnet --info
script:
- chmod +x build.sh
- ./build.sh
- ./build.sh
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: 1.0.{build}
image: Visual Studio 2017

install:
- ps: iwr https://raw.githubusercontent.com/dotnet/cli/release/2.1.3xx/scripts/obtain/dotnet-install.ps1 -outfile dotnet-install.ps1
- ps: .\dotnet-install.ps1 -Version 2.1.300-preview2-008530 -InstallDir $env:ProgramFiles/dotnet
- cmd: choco install dotnet.script

build_script:
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ if [ ! -d "$DOTNET_SCRIPT" ]; then
exit 1
fi
fi
dotnet "$DOTNET_SCRIPT/dotnet-script.dll" "$SCRIPT_DIR/build/Build.csx" -- "$SCRIPT_DIR"
dotnet "$DOTNET_SCRIPT/dotnet-script.dll" "$SCRIPT_DIR/build/Build.csx" "--debug" -- "$SCRIPT_DIR"
71 changes: 65 additions & 6 deletions build/Build.csx
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
#! "netcoreapp2.0"
#load "nuget:Dotnet.Build, 0.2.9"
#load "nuget:Dotnet.Build, 0.3.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what changed here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to add the possibility to specify the target framework when doing DotNet.Publish since we now have multiple target frameworks. Otherwise nothing much to write home about 👍

#load "nuget:github-changelog, 0.1.4"
#load "Choco.csx"
#load "BuildContext.csx"

using static ReleaseManagement;
using static ChangeLog;
using static FileUtils;
using System.Xml.Linq;



DotNet.Build(DotnetScriptProjectFolder);
DotNet.Test(TestProjectFolder);
DotNet.Publish(DotnetScriptProjectFolder, PublishArtifactsFolder);
DotNet.Publish(DotnetScriptProjectFolder, PublishArtifactsFolder, NetCoreApp20);

// We only publish packages from Windows/AppVeyor
if (BuildEnvironment.IsWindows)
{
NuGet.PackAsTool(DotnetScriptProjectFolder,PublishArtifactsFolder,NuGetArtifactsFolder);
DotNet.Pack(DotnetScriptProjectFolder, NuGetArtifactsFolder);
{

using(var globalToolBuildFolder = new DisposableFolder())
{
Copy(SolutionFolder, globalToolBuildFolder.Path);
PatchTargetFramework(globalToolBuildFolder.Path, NetCoreApp21);
PatchPackAsTool(globalToolBuildFolder.Path);
PatchPackageId(globalToolBuildFolder.Path, GlobalToolPackageId);
PatchContent(globalToolBuildFolder.Path);
DotNet.Pack(Path.Combine(globalToolBuildFolder.Path,"Dotnet.Script"),NuGetArtifactsFolder);
}

using(var nugetPackageBuildFolder = new DisposableFolder())
{
Copy(SolutionFolder, nugetPackageBuildFolder.Path);
PatchTargetFramework(nugetPackageBuildFolder.Path, NetCoreApp20);
DotNet.Pack(Path.Combine(nugetPackageBuildFolder.Path,"Dotnet.Script"),NuGetArtifactsFolder);
}

DotNet.Pack(DotnetScriptCoreProjectFolder, NuGetArtifactsFolder);
DotNet.Pack(DotnetScriptDependencyModelProjectFolder, NuGetArtifactsFolder);
DotNet.Pack(DotnetScriptDependencyModelNuGetProjectFolder, NuGetArtifactsFolder);

Choco.Pack(DotnetScriptProjectFolder, PublishArtifactsFolder, ChocolateyArtifactsFolder);
Zip(PublishArchiveFolder, PathToGitHubReleaseAsset);

if (BuildEnvironment.IsSecure)
{
await CreateReleaseNotes();
Expand All @@ -48,3 +68,42 @@ private async Task CreateReleaseNotes()
}
await generator.Generate(PathToReleaseNotes);
}

private void PatchTargetFramework(string solutionFolder, string targetFramework)
{
var pathToDotnetScriptProject = Path.Combine(solutionFolder,"Dotnet.Script","Dotnet.Script.csproj");
var projectFile = XDocument.Load(pathToDotnetScriptProject);
var targetFrameworksElement = projectFile.Descendants("TargetFrameworks").Single();
targetFrameworksElement.ReplaceWith(new XElement("TargetFramework",targetFramework));
projectFile.Save(pathToDotnetScriptProject);
}

private void PatchPackAsTool(string solutionFolder)
{
var pathToDotnetScriptProject = Path.Combine(solutionFolder,"Dotnet.Script","Dotnet.Script.csproj");
var projectFile = XDocument.Load(pathToDotnetScriptProject);
var packAsToolElement = projectFile.Descendants("PackAsTool").Single();
packAsToolElement.Value = "true";
projectFile.Save(pathToDotnetScriptProject);
}

private void PatchPackageId(string solutionFolder, string packageId)
{
var pathToDotnetScriptProject = Path.Combine(solutionFolder,"Dotnet.Script","Dotnet.Script.csproj");
var projectFile = XDocument.Load(pathToDotnetScriptProject);
var packAsToolElement = projectFile.Descendants("PackageId").Single();
packAsToolElement.Value = packageId;
projectFile.Save(pathToDotnetScriptProject);
}

private void PatchContent(string solutionFolder)
{
var pathToDotnetScriptProject = Path.Combine(solutionFolder,"Dotnet.Script","Dotnet.Script.csproj");
var projectFile = XDocument.Load(pathToDotnetScriptProject);
var contentElements = projectFile.Descendants("Content").ToArray();
foreach (var contentElement in contentElements)
{
contentElement.Remove();
}
projectFile.Save(pathToDotnetScriptProject);
}
12 changes: 10 additions & 2 deletions build/BuildContext.csx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#load "nuget:Dotnet.Build, 0.2.9"
#load "nuget:Dotnet.Build, 0.3.1"
using static FileUtils;
using System.Xml.Linq;

const string NetCoreApp20 = "netcoreapp2.0";

const string NetCoreApp21 = "netcoreapp2.1";

const string GlobalToolPackageId = "dotnet-script";

string Version;

string GitHubArtifactsFolder;
Expand All @@ -18,6 +24,8 @@ string PublishArtifactsFolder;

string PublishArchiveFolder;

string SolutionFolder;

string DotnetScriptProjectFolder;

string DotnetScriptCoreProjectFolder;
Expand All @@ -41,7 +49,7 @@ string ProjectName;
Owner = "filipw";
ProjectName = "dotnet-script";
Root = FileUtils.GetScriptFolder();

SolutionFolder = Path.Combine(Root,"..","src");
DotnetScriptProjectFolder = Path.Combine(Root, "..", "src", "Dotnet.Script");
DotnetScriptCoreProjectFolder = Path.Combine(Root, "..", "src", "Dotnet.Script.Core");
DotnetScriptDependencyModelProjectFolder = Path.Combine(Root, "..", "src", "Dotnet.Script.DependencyModel");
Expand Down
2 changes: 1 addition & 1 deletion build/Choco.csx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#load "nuget:Dotnet.Build, 0.2.9"
#load "nuget:Dotnet.Build, 0.3.1"

using System.Xml.Linq;

Expand Down
2 changes: 1 addition & 1 deletion src/Dotnet.Script.Core/Dotnet.Script.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A cross platform library allowing you to run C# (CSX) scripts from a project.json dependency definition file and with support for debugging. Based on Roslyn.</Description>
<VersionPrefix>0.21.0</VersionPrefix>
<VersionPrefix>0.22.0</VersionPrefix>
<Authors>filipw</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Dotnet.Script.Core</AssemblyName>
Expand Down
5 changes: 2 additions & 3 deletions src/Dotnet.Script.Core/Internal/ScriptExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ namespace Dotnet.Script.Core.Internal
{
internal static class ScriptExtensions
{
public static IEnumerable<Diagnostic> GetDiagnostics<T>(this Script<T> script, IEnumerable<string> suppressedDiagnosticIds)
public static IEnumerable<Diagnostic> GetDiagnostics<T>(this Script<T> script)
{
var compilation = script.GetCompilation();
var diagnostics = compilation.GetDiagnostics().Where(d => !suppressedDiagnosticIds.Contains(d.Id));
var orderedDiagnostics = diagnostics.OrderBy((d1, d2) =>
var orderedDiagnostics = compilation.GetDiagnostics().OrderBy((d1, d2) =>
{
var severityDiff = (int)d2.Severity - (int)d1.Severity;
return severityDiff != 0 ? severityDiff : d1.Location.SourceSpan.Start - d2.Location.SourceSpan.Start;
Expand Down
Loading