Skip to content

Commit

Permalink
Merge pull request #472 from seesharper/issue457
Browse files Browse the repository at this point in the history
Added support for SDK style source packages
  • Loading branch information
seesharper authored Jan 25, 2019
2 parents 0f1c704 + 257a12b commit 3e6cc04
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"program": "dotnet",
"args": [
"exec",
"/Users/bernhardrichter/.dotnet/tools/.store/dotnet-script/0.27.1/dotnet-script/0.27.1/tools/netcoreapp2.1/any/dotnet-script.dll"
"/Users/bernhardrichter/.dotnet/tools/.store/dotnet-script/0.28.0/dotnet-script/0.28.0/tools/netcoreapp2.1/any/dotnet-script.dll"
"${file}"
],
"cwd": "${workspaceRoot}",
Expand Down
17 changes: 10 additions & 7 deletions build/LightInject.Source.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
<releaseNotes>http://www.lightinject.net/#whatsnew</releaseNotes>
<copyright>Bernhard Richter</copyright>
<tags>Ioc Dependency-Injection Inversion-of-Control WinRT Windows-Runtime</tags>
<dependencies>
<group targetFramework=".NETFramework4.5" />
<group targetFramework=".NETFramework4.6" />
</dependencies>
<contentFiles>
<files include="cs/netstandard2.0/LightInject.cs.pp" />
<files include="cs/netcoreapp2.0/LightInject.cs.pp" />
<files include="cs/net46/LightInject.cs.pp" />
</contentFiles>
</metadata>
<files>
<file src="content\net45\LightInject\LightInject.cs.pp" target="content\net45\LightInject.Interception\LightInject.cs.pp" />
</files>
<files>
<file src="contentFiles/cs/netstandard2.0/LightInject/LightInject.cs.pp" target="contentFiles/cs/netstandard2.0/LightInject/LightInject.cs.pp" />
<file src="contentFiles/cs/netcoreapp2.0/LightInject/LightInject.cs.pp" target="contentFiles/cs/netcoreapp2.0/LightInject/LightInject.cs.pp" />
<file src="contentFiles/cs/net46/LightInject/LightInject.cs.pp" target="contentFiles/cs/net46/LightInject/LightInject.cs.pp" />
</files>
</package>
26 changes: 19 additions & 7 deletions build/build.csx
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ using static xUnit;
using static DotNet;
using static ChangeLog;
using static ReleaseManagement;
using System.Text.RegularExpressions;

Build(projectFolder);
Test(testProjectFolder);
//AnalyzeCodeCoverage(pathToTestAssembly, $"+[{projectName}]*");
Pack(projectFolder, nuGetArtifactsFolder, Git.Default.GetCurrentShortCommitHash());

using(var sourceRepoFolder = new DisposableFolder())
using (var sourceRepoFolder = new DisposableFolder())
{
string pathToSourceProjectFolder = Path.Combine(sourceRepoFolder.Path,"src","LightInject");
string pathToSourceFile = Path.Combine(pathToSourceProjectFolder, "LightInject.cs");
Copy(repoFolder, sourceRepoFolder.Path, new [] {".vs", "obj"});
Internalize(pathToSourceProjectFolder, exceptTheseTypes);
DotNet.Build(Path.Combine(sourceRepoFolder.Path,"src","LightInject"));
using(var nugetPackFolder = new DisposableFolder())
{
var contentFolder = CreateDirectory(nugetPackFolder.Path, "content","net45", "LightInject");
Copy("LightInject.Source.nuspec", nugetPackFolder.Path);
string pathToSourceFileTemplate = Path.Combine(contentFolder, "LightInject.cs.pp");
Copy(Path.Combine(pathToSourceProjectFolder, "LightInject.cs"), pathToSourceFileTemplate);
FileUtils.ReplaceInFile(@"namespace \S*", $"namespace $rootnamespace$.{projectName}", pathToSourceFileTemplate);
PrepareSourceFile(nugetPackFolder.Path, pathToSourceFile, "netcoreapp2.0");
PrepareSourceFile(nugetPackFolder.Path, pathToSourceFile, "netstandard2.0");
PrepareSourceFile(nugetPackFolder.Path, pathToSourceFile, "net46");
NuGet.Pack(nugetPackFolder.Path, nuGetArtifactsFolder, version);
}
}
Expand All @@ -43,7 +43,7 @@ if (BuildEnvironment.IsSecure)
}
}

private async Task CreateReleaseNotes()
private async Task CreateReleaseNotes()
{
Logger.Log("Creating release notes");
var generator = ChangeLogFrom(owner, projectName, BuildEnvironment.GitHubAccessToken).SinceLatestTag();
Expand All @@ -52,4 +52,16 @@ if (BuildEnvironment.IsSecure)
generator = generator.IncludeUnreleased();
}
await generator.Generate(pathToReleaseNotes, FormattingOptions.Default.WithPullRequestBody());
}

private void PrepareSourceFile(string nugetPackFolder, string pathToSourceFile ,string targetFramework)
{
var contentFolder = CreateDirectory(nugetPackFolder, "contentFiles", "cs", targetFramework, "LightInject");
string pathToSourceFileTemplate = Path.Combine(contentFolder, "LightInject.cs.pp");
Copy(pathToSourceFile, pathToSourceFileTemplate);
var frameworkConstant = targetFramework.ToUpper().Replace(".","_");
var lines = File.ReadAllLines(pathToSourceFileTemplate).ToList();
lines.Insert(0, $"#define {frameworkConstant}");
File.WriteAllLines(pathToSourceFileTemplate, lines);
FileUtils.ReplaceInFile(@"namespace \S*", $"namespace $rootnamespace$.{projectName}", pathToSourceFileTemplate);
}
5 changes: 2 additions & 3 deletions src/LightInject/LightInject.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*********************************************************************************
The MIT License (MIT)
Copyright (c) 2018 bernhard.richter@gmail.com
Copyright (c) 2019 bernhard.richter@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,7 +21,7 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************
LightInject version 5.3.0
LightInject version 5.4.0
http://www.lightinject.net/
http://twitter.com/bernhardrichter
******************************************************************************/
Expand All @@ -34,7 +34,6 @@ LightInject version 5.3.0
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Performance")]
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("MaintainabilityRules", "SA1403", Justification = "One source file")]
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("DocumentationRules", "SA1649", Justification = "One source file")]

namespace LightInject
{
using System;
Expand Down

0 comments on commit 3e6cc04

Please sign in to comment.