Skip to content

Commit

Permalink
Merge pull request dotnet#416 from sokket/nuget
Browse files Browse the repository at this point in the history
Adding files to generate a NuGet package for the System.Buffers on every official build
  • Loading branch information
Jonathan Miller committed Nov 6, 2015
2 parents d95760e + c7c324c commit fec5a8c
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 1 deletion.
18 changes: 17 additions & 1 deletion netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,20 @@ def project = 'dotnet/corefxlab'
// See the documentation for this function to see additional optional parameters.
Utilities.simpleInnerLoopJobSetup(newJob, project, isPR, "Windows ${configuration}")
}
}
}

[false].each { isPR -> // We only want to generate nuget packages for official builds
def nugetJobName = Utilities.getFullJobName(project, 'Debug', isPR)

def nugetCommand = """call package.cmd"""

def nugetJob = job(nugetJobName) {
label('windows')

steps {
batchFile(nugetCommand)
}
}

Utilities.simpleInnerLoopJobSetup(nugetJob, project, isPR, "Generate System.Buffer NuGet Package")
}
53 changes: 53 additions & 0 deletions package.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@echo off
setlocal

:: Note: We've disabled node reuse because it causes file locking issues.
:: The issue is that we extend the build with our own targets which
:: means that that rebuilding cannot successfully delete the task
:: assembly.

if not defined VisualStudioVersion (
if defined VS140COMNTOOLS (
call "%VS140COMNTOOLS%\VsDevCmd.bat"
goto :EnvSet
)

if defined VS120COMNTOOLS (
call "%VS120COMNTOOLS%\VsDevCmd.bat"
goto :EnvSet
)

echo Error: build.cmd requires Visual Studio 2013 or 2015.
echo Please see https://github.com/dotnet/corefx/blob/master/Documentation/developer-guide.md for build instructions.
exit /b 1
)

:EnvSet

:: Log build command line
set _buildproj=%~dp0build.proj
set _buildlog=%~dp0msbuild.log
set _buildprefix=echo
set _buildpostfix=^> "%_buildlog%"
call :build %*

:: Build
set _buildprefix=
set _buildpostfix=
call :build %*

goto :AfterBuild

:build
%_buildprefix% msbuild "src/System.Buffers/src/System.Buffers.csproj" /t:BuildPackages /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=normal;LogFile="%_buildlog%";Append %* %_buildpostfix%
set BUILDERRORLEVEL=%ERRORLEVEL%
goto :eof

:AfterBuild

echo.
:: Pull the build summary from the log file
findstr /ir /c:".*Warning(s)" /c:".*Error(s)" /c:"Time Elapsed.*" "%_buildlog%"
echo Build Exit Code = %BUILDERRORLEVEL%

exit /b %BUILDERRORLEVEL%
1 change: 1 addition & 0 deletions src/System.Buffers/src/System.Buffers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
<Compile Include="System\Diagnostics\Precondition.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<Import Project="../../publish-nuget.target" />
</Project>
22 changes: 22 additions & 0 deletions src/System.Buffers/src/System.Buffers.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>System.Buffers</id>
<version>4.0.0-beta</version>
<title>System.Buffers</title>
<authors>Microsoft Corporation</authors>
<owners>Microsoft Corporation</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<licenseUrl>http://go.microsoft.com/fwlink/?LinkId=329770</licenseUrl>
<projectUrl>http://go.microsoft.com/fwlink/?LinkId=518631</projectUrl>
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>
<description>Pre-release of the System.Buffers namespace</description>
<releaseNotes>Pre-release of the System.Buffers namespace</releaseNotes>
<copyright>Copyright Microsoft Corporation 2015</copyright>
<tags>System.Buffers BufferPool Buffer</tags>
</metadata>
<files>
<file src="..\..\bin\Windows_NT.AnyCPU.Debug\System.Buffers\System.Buffers.dll" target="lib" />
<file src="..\..\bin\Windows_NT.AnyCPU.Debug\System.Buffers\System.Slices.dll" target="lib" />
</files>
</package>
53 changes: 53 additions & 0 deletions src/publish-nuget.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<PackagesNuSpecFiles Include="*.nuspec" />
</ItemGroup>

<PropertyGroup>
<PackagesOutDir Condition="'$(PackagesOutDir)' == ''">$(OutDir)Packages\</PackagesOutDir>
<PackagesBasePath Condition="'$(PackagesBasePath)' == ''">$(OutDir)</PackagesBasePath>
</PropertyGroup>

<PropertyGroup>
<NuGetExe>&quot;$(NuGetToolPath)&quot;</NuGetExe>
<NuGetBasePath>&quot;$(PackagesBasePath.TrimEnd('\'))&quot;</NuGetBasePath>
<NuGetOutputDirectory>&quot;$(PackagesOutDir.TrimEnd('\'))&quot;</NuGetOutputDirectory>
</PropertyGroup>

<Target Name="BuildPackages"
Condition="'$(SkipBuildPackages)' != 'true'">

<!-- Create package output directory -->
<MakeDir Directories="$(PackagesOutDir)" />

<!-- Make package -->
<!-- We ignore warnings because NuGet will warn when libraries are not placed
in framework specific subfolders. Our build tools do this because the
libraries are used during build, and do not depend on the framework being
targeted by the build -->
<!-- We trim the last backslash from properties which could end with one,
to prevent it from escaping the closing quote -->
<Exec
Condition="'@(PackagesNuSpecFiles)'!=''"
IgnoreStandardErrorWarningFormat="true"
StandardOutputImportance="Low"
Command="$(NuGetExe) pack &quot;%(PackagesNuSpecFiles.FullPath)&quot; -BasePath $(NuGetBasePath) -OutputDirectory $(NuGetOutputDirectory) $(ProductVersion)" />

<Message
Condition="'@(PackagesNuSpecFiles)'!=''"
Importance="High"
Text="%(PackagesNuSpecFiles.Filename) NuGet Package -> $(PackagesOutDir)%(PackagesNuSpecFiles.Filename).%(PackagesNuSpecFiles.PackageVersion).nupkg" />

<ItemGroup>
<PackagesForPublishing Include="$(PackagesOutDir)*.nupkg" />
</ItemGroup>

<!-- push all packages to a server if one has been specified -->
<Exec
Condition="'@(PackagesForPublishing)' != '' and '$(PublishPackageSource)' != ''"
Command="$(NuGetExe) push &quot;%(PackagesForPublishing.Identity)&quot; -s $(PublishPackageSource)" />

</Target>
</Project>

0 comments on commit fec5a8c

Please sign in to comment.