Create a build configuraition to build OOB logging site extension package (#3643)

This commit is contained in:
Pavel Krymets 2018-10-19 12:19:33 -07:00 committed by GitHub
parent 7f34909708
commit d3216a66c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 452 additions and 0 deletions

View File

@ -0,0 +1,38 @@
trigger:
branches:
include:
- release/2.2
phases:
- phase: SiteExtensions
variables:
CI: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# This variable is required by MicroBuildSigningPlugin to determine permissions for codesigning.
TeamName: AspNetCore
# SignType = { test, real }
# This is prefixed underscore because variables automatically become environment variables (and therefore MSBuild properties),
# and this one was causing issues in MSBuild projects which use the $(SignType) MSbuild prop.
_SignType: real
steps:
- task: MicroBuildSigningPlugin@1
displayName: Install MicroBuild plugin
condition: and(succeeded(), in(variables['_SignType'], 'test', 'real'))
inputs:
signType: $(_SignType)
zipSources: false
- script: src/SiteExtensions/build.cmd -ci
displayName: Run src/SiteExtensions/build.cmd
- task: PublishBuildArtifacts@1
displayName: Upload artifacts
condition: eq(variables['system.pullrequest.isfork'], false)
inputs:
pathtoPublish: ./src/SiteExtensions/artifacts/
artifactName: artifacts-Windows-Release
artifactType: Container
- task: MicroBuildCleanup@1
displayName: Cleanup MicroBuild tasks
condition: always()

View File

@ -0,0 +1,9 @@
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
<Import Project="build\sources.props" />
<Import Project="build\dependencies.props" />
<Import Project="version.props" />
</Project>

View File

@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0ED05384-4F64-44BA-A4AA-47519DA26E8C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.AzureAppServices.SiteExtension", "src\Microsoft.AspNetCore.AzureAppServices.SiteExtension\Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj", "{69E22952-302D-4C56-B2BE-7C086EB05C79}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Web.Xdt.Extensions", "src\Microsoft.Web.Xdt.Extensions\Microsoft.Web.Xdt.Extensions.csproj", "{637E1D65-7F1C-476B-AD0A-30B295DF5414}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Debug|x64.ActiveCfg = Debug|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Debug|x64.Build.0 = Debug|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Debug|x86.ActiveCfg = Debug|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Debug|x86.Build.0 = Debug|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Release|Any CPU.Build.0 = Release|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Release|x64.ActiveCfg = Release|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Release|x64.Build.0 = Release|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Release|x86.ActiveCfg = Release|Any CPU
{69E22952-302D-4C56-B2BE-7C086EB05C79}.Release|x86.Build.0 = Release|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Debug|Any CPU.Build.0 = Debug|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Debug|x64.ActiveCfg = Debug|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Debug|x64.Build.0 = Debug|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Debug|x86.ActiveCfg = Debug|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Debug|x86.Build.0 = Debug|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Release|Any CPU.ActiveCfg = Release|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Release|Any CPU.Build.0 = Release|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Release|x64.ActiveCfg = Release|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Release|x64.Build.0 = Release|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Release|x86.ActiveCfg = Release|Any CPU
{637E1D65-7F1C-476B-AD0A-30B295DF5414}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{69E22952-302D-4C56-B2BE-7C086EB05C79} = {0ED05384-4F64-44BA-A4AA-47519DA26E8C}
{637E1D65-7F1C-476B-AD0A-30B295DF5414} = {0ED05384-4F64-44BA-A4AA-47519DA26E8C}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,3 @@
@ECHO OFF
SET RepoRoot="%~dp0..\.."
%RepoRoot%\build.cmd -LockFile %RepoRoot%\korebuild-lock.txt -Path %~dp0 %*

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
repo_root="$DIR/../.."
"$repo_root/build.sh" --path "$DIR" --lockfile "$repo_root/korebuild-lock.txt" "$@"

View File

@ -0,0 +1,13 @@
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview2-20181004.6</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAzureAppServicesSiteExtension21PackageVersion>2.1.1-rtm-31076</MicrosoftAspNetCoreAzureAppServicesSiteExtension21PackageVersion>
<MicrosoftAspNetCoreAzureAppServicesSiteExtension22PackageVersion>2.2.0-rtm-35515</MicrosoftAspNetCoreAzureAppServicesSiteExtension22PackageVersion>
<MicrosoftWebXdtPackageVersion>1.4.0</MicrosoftWebXdtPackageVersion>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,8 @@
<Project>
<ItemGroup>
<ExcludeFromPack Include="$(RepositoryRoot)src\Microsoft.Web.Xdt.Extensions\*.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<RestoreSources>
$(RestoreSources);
https://api.nuget.org/v3/index.json;
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
</RestoreSources>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,8 @@
{
"sdk": {
"version": "2.2.100-preview2-009404"
},
"msbuild-sdks": {
"Internal.AspNetCore.Sdk": "2.2.0-preview2-20181011.10"
}
}

View File

@ -0,0 +1,7 @@
<Project>
<Import Project="..\Directory.Build.props" />
<ItemGroup>
<PackageReference Include="Internal.AspNetCore.Sdk" PrivateAssets="All" Version="$(InternalAspNetCoreSdkPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<title>ASP.NET Core Logging Extensions</title>
<Description>This extension enables additional functionality for ASP.NET Core on Azure WebSites, such as enabling Azure logging.</Description>
<TargetFramework>net461</TargetFramework>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<PackageTags>aspnet;logging;aspnetcore;AzureSiteExtension;keyvault;configuration;dataprotection</PackageTags>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<PackageType>AzureSiteExtension</PackageType>
<NoPackageAnalysis>true</NoPackageAnalysis>
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeSymbols>false</IncludeSymbols>
<IncludeSource>false</IncludeSource>
<ContentTargetFolders>content</ContentTargetFolders>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.2.1" Version="$(MicrosoftAspNetCoreAzureAppServicesSiteExtension21PackageVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.2.2" Version="$(MicrosoftAspNetCoreAzureAppServicesSiteExtension22PackageVersion)" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Content Include="applicationHost.xdt" />
<Content Include="scmApplicationHost.xdt" />
<Content Include="bin\$(Configuration)\$(TargetFramework)\Microsoft.Web.Xdt.Extensions.dll" PackagePath="content" />
<SignedPackageFile
Include="bin\$(Configuration)\$(TargetFramework)\Microsoft.Web.Xdt.Extensions.dll"
PackagePath="content/Microsoft.Web.Xdt.Extensions.dll"
Certificate="$(AssemblySigningCertName)" Visible="false" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Web.Xdt.Extensions\Microsoft.Web.Xdt.Extensions.csproj" PrivateAssets="All" />
</ItemGroup>
<Target Name="AddContent" BeforeTargets="_GetPackageFiles;GetSignedPackageFiles">
<ItemGroup>
<ContentFilesToPack Include="$(NugetPackageRoot)\%(PackageReference.Identity)\%(PackageReference.Version)\content\**\*.*" />
<!-- Temporarily skip the common files -->
<FilteredContentFilesToPack Include="@(ContentFilesToPack)" Condition="'%(RecursiveDir)' != ''" />
<None Include="@(FilteredContentFilesToPack)" PackagePath="content\%(RecursiveDir)%(Filename)%(Extension)" Pack="true" />
<ExcludePackageFileFromSigning Include="@(FilteredContentFilesToPack)" PackagePath="content\%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
</Target>
</Project>

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<xdt:Import path="%XDT_EXTENSIONPATH%\Microsoft.Web.Xdt.Extensions.dll"
namespace="Microsoft.Web.Xdt.Extensions" />
<system.webServer xdt:Transform="InsertIfMissing">
<runtime xdt:Transform="InsertIfMissing" >
<environmentVariables xdt:Transform="InsertIfMissing">
<add name="DOTNET_ADDITIONAL_DEPS" value="%XDT_EXTENSIONPATH%\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\" xdt:Locator="Match(name)" xdt:Transform="InsertOrAppendAttribute(Attribute='value')" />
<add name="DOTNET_SHARED_STORE" value="%XDT_EXTENSIONPATH%\store" xdt:Locator="Match(name)" xdt:Transform="InsertOrAppendAttribute(Attribute='value')" />
<add name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" value="Microsoft.AspNetCore.AzureAppServices.HostingStartup" xdt:Locator="Match(name)" xdt:Transform="InsertOrAppendAttribute(Attribute='value')" />
</environmentVariables>
</runtime>
</system.webServer>
</configuration>

View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- This file exists to prevent applicationHost.xdt from being applied to scm host that runs
other dotnet processes (dotnet build, csc etc. )-->
</configuration>

View File

@ -0,0 +1,144 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Xml;
using Microsoft.Web.XmlTransform;
namespace Microsoft.Web.Xdt.Extensions
{
/// <summary>
/// Insert or append to the given attribute
/// </summary>
public class InsertOrAppendAttribute : Transform
{
/// <summary>
///
/// </summary>
public InsertOrAppendAttribute()
: base(TransformFlags.UseParentAsTargetNode, MissingTargetMessage.Error)
{
}
private string _attributeName;
/// <summary>
///
/// </summary>
protected string AttributeName
{
get
{
if (_attributeName == null)
{
_attributeName = GetArgumentValue("Attribute");
}
return _attributeName;
}
}
/// <summary>
/// Extracts a value from the arguments provided
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
protected string GetArgumentValue(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
string result = null;
if (Arguments != null && Arguments.Count > 0)
{
foreach (var arg in Arguments)
{
if (!string.IsNullOrEmpty(arg))
{
var trimmedArg = arg.Trim();
if (trimmedArg.StartsWith(name, StringComparison.OrdinalIgnoreCase))
{
var start = arg.IndexOf('\'');
var last = arg.LastIndexOf('\'');
if (start <= 0 || last <= 0 || last <= start)
{
throw new ArgumentException("Expected two ['] characters");
}
var value = trimmedArg.Substring(start, last - start);
// remove any leading or trailing '
value = value.Trim().TrimStart('\'').TrimStart('\'');
result = value;
}
}
}
}
return result;
}
/// <summary>
///
/// </summary>
protected override void Apply()
{
if (TargetChildNodes == null || TargetChildNodes.Count == 0)
{
TargetNode.AppendChild(TransformNode);
}
else
{
XmlAttribute transformAtt = null;
foreach (XmlAttribute att in TransformNode.Attributes)
{
if (string.Equals(att.Name, AttributeName, StringComparison.OrdinalIgnoreCase))
{
transformAtt = att;
break;
}
}
if (transformAtt == null)
{
throw new InvalidOperationException("No target attribute to append");
}
foreach (XmlNode targetNode in TargetChildNodes)
{
var foundAttribute = false;
foreach (XmlAttribute att in targetNode.Attributes)
{
if (string.Equals(att.Name, AttributeName, StringComparison.OrdinalIgnoreCase))
{
foundAttribute = true;
if (string.IsNullOrEmpty(att.Value))
{
att.Value = transformAtt.Value;
}
else
{
// TODO: This doesn't compose well with insertOrAppend being applied on the TargetNode.
// The target node is created with the children it has in the transform, which means we would
// duplicate the value here.
if (att.Value == transformAtt.Value)
{
return;
}
att.Value = $"{att.Value};{transformAtt.Value}";
}
}
}
if (!foundAttribute)
{
var attribute = targetNode.OwnerDocument.CreateAttribute(AttributeName);
attribute.Value = transformAtt.Value;
targetNode.Attributes.Append(attribute);
}
}
}
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Additional functionality for Xdt transforms.</Description>
<TargetFramework>net461</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>xdt</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.Xdt" Version="$(MicrosoftWebXdtPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,53 @@
{
"AssemblyIdentity": "Microsoft.Web.Xdt.Extensions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
"Types": [
{
"Name": "Microsoft.Web.Xdt.Extensions.InsertOrAppendAttribute",
"Visibility": "Public",
"Kind": "Class",
"BaseType": "Microsoft.Web.XmlTransform.Transform",
"ImplementedInterfaces": [],
"Members": [
{
"Kind": "Method",
"Name": "get_AttributeName",
"Parameters": [],
"ReturnType": "System.String",
"Visibility": "Protected",
"GenericParameter": []
},
{
"Kind": "Method",
"Name": "GetArgumentValue",
"Parameters": [
{
"Name": "name",
"Type": "System.String"
}
],
"ReturnType": "System.String",
"Visibility": "Protected",
"GenericParameter": []
},
{
"Kind": "Method",
"Name": "Apply",
"Parameters": [],
"ReturnType": "System.Void",
"Virtual": true,
"Override": true,
"Visibility": "Protected",
"GenericParameter": []
},
{
"Kind": "Constructor",
"Name": ".ctor",
"Parameters": [],
"Visibility": "Public",
"GenericParameter": []
}
],
"GenericParameters": []
}
]
}

View File

@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<VersionPrefix>2.2.0</VersionPrefix>
<VersionSuffix>rtm</VersionSuffix>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
<BuildNumber Condition="'$(BuildNumber)' == ''">t000</BuildNumber>
<FeatureBranchVersionPrefix Condition="'$(FeatureBranchVersionPrefix)' == ''">a-</FeatureBranchVersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(FeatureBranchVersionSuffix)' != ''">$(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-'))</VersionSuffix>
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
</Project>