#21 Initial site extension and packaging
This commit is contained in:
parent
4463144186
commit
52be2b750e
|
|
@ -1,6 +1,6 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26401.1
|
||||
VisualStudioVersion = 15.0.26406.2
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.AzureAppServicesIntegration", "src\Microsoft.AspNetCore.AzureAppServicesIntegration\Microsoft.AspNetCore.AzureAppServicesIntegration.csproj", "{5916BEB5-0969-469B-976C-A392E015DFAC}"
|
||||
EndProject
|
||||
|
|
@ -29,6 +29,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Applic
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationInsightsHostingStartupSample", "sample\ApplicationInsightsHostingStartupSample\ApplicationInsightsHostingStartupSample.csproj", "{33E245F0-2566-4B5B-BA7C-8895B7A697AE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Web.Xdt.Extensions", "src\Microsoft.Web.Xdt.Extensions\Microsoft.Web.Xdt.Extensions.csproj", "{9B22E525-FEC9-4C7C-9F9C-598C15BD0250}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.AzureAppServices.SiteExtension", "src\Microsoft.AspNetCore.AzureAppServices.SiteExtension\Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj", "{1CE2D76B-39E6-46C0-8F6F-C63E370955A9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -63,6 +67,14 @@ Global
|
|||
{33E245F0-2566-4B5B-BA7C-8895B7A697AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{33E245F0-2566-4B5B-BA7C-8895B7A697AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{33E245F0-2566-4B5B-BA7C-8895B7A697AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9B22E525-FEC9-4C7C-9F9C-598C15BD0250}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9B22E525-FEC9-4C7C-9F9C-598C15BD0250}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9B22E525-FEC9-4C7C-9F9C-598C15BD0250}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9B22E525-FEC9-4C7C-9F9C-598C15BD0250}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1CE2D76B-39E6-46C0-8F6F-C63E370955A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1CE2D76B-39E6-46C0-8F6F-C63E370955A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1CE2D76B-39E6-46C0-8F6F-C63E370955A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1CE2D76B-39E6-46C0-8F6F-C63E370955A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -75,5 +87,7 @@ Global
|
|||
{939EA897-CA31-4F2E-BA51-22B570B64671} = {37237C93-6855-40D9-9E60-418B093EF49A}
|
||||
{2849A2D9-7C08-4198-BF2B-8BFB4B13554D} = {FF9B744E-6C59-40CC-9E41-9D2EBD292435}
|
||||
{33E245F0-2566-4B5B-BA7C-8895B7A697AE} = {37237C93-6855-40D9-9E60-418B093EF49A}
|
||||
{9B22E525-FEC9-4C7C-9F9C-598C15BD0250} = {FF9B744E-6C59-40CC-9E41-9D2EBD292435}
|
||||
{1CE2D76B-39E6-46C0-8F6F-C63E370955A9} = {FF9B744E-6C59-40CC-9E41-9D2EBD292435}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -4,7 +4,14 @@
|
|||
"AdxVerificationCompositeRule"
|
||||
],
|
||||
"packages": {
|
||||
"Microsoft.AspNetCore.AzureAppServicesIntegration": { }
|
||||
"Microsoft.AspNetCore.AzureAppServicesIntegration": { },
|
||||
"Microsoft.AspNetCore.AzureAppServices.SiteExtension": {
|
||||
"Exclusions": {
|
||||
"THIRDPARTY_DEPENDENCY_NOT_REGISTERED": {
|
||||
"Microsoft.AspNetCore.AzureAppServices.SiteExtension; .NETFramework,Version=v4.5.1": "Microsoft.Web.Xdt.Extensions is locally developed and bundled into this package."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Default": { // Rules to run for packages not listed in any other set.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
|
||||
<RuntimeFrameworkVersion>2.0.0-*</RuntimeFrameworkVersion>
|
||||
<TestSdkVersion>15.0.0</TestSdkVersion>
|
||||
<XdtVersion>1.4.0</XdtVersion>
|
||||
<XunitVersion>2.2.0</XunitVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<title>ASP.NET Core Extensions</title>
|
||||
<Description>This extension enables additional functionality for ASP.NET Core on Azure WebSites, such as enabling Azure logging.</Description>
|
||||
<TargetFramework>net451</TargetFramework>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
<PackageTags>aspnet;logging;aspnetcore</PackageTags>
|
||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||
<ContentTargetFolders>content</ContentTargetFolders>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="applicationHost.xdt" />
|
||||
<Content Include="bin\$(Configuration)\net451\Microsoft.Web.Xdt.Extensions.dll" PackagePath="content" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.Web.Xdt.Extensions\Microsoft.Web.Xdt.Extensions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?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%\deps" 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>
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
// 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)
|
||||
{
|
||||
foreach (XmlAttribute att in targetNode.Attributes)
|
||||
{
|
||||
if (string.Equals(att.Name, AttributeName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>Additional functionality for Xdt transforms.</Description>
|
||||
<TargetFramework>net451</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>xdt</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Web.Xdt" Version="$(XdtVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in New Issue