Skip to content

Commit 8fb397f

Browse files
authored
feat:Add support for PackageReference with NewRelic.Azure.WebSites packages. (#3001)
1 parent 31689d6 commit 8fb397f

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

build/ArtifactBuilder/Artifacts/NugetAzureWebSites.cs

+25-8
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,46 @@ public NugetAzureWebSites(string platform, string configuration)
2121
private readonly AgentComponents _frameworkAgentComponents;
2222
private string _nuGetPackageName;
2323

24-
private string RootDirectory => $@"{StagingDirectory}\content\newrelic";
25-
2624
protected override void InternalBuild()
2725
{
26+
var rootDirectory = $@"{StagingDirectory}\content\newrelic";
2827
_frameworkAgentComponents.ValidateComponents();
2928

3029
var package = new NugetPackage(StagingDirectory, OutputDirectory);
30+
3131
_frameworkAgentComponents.CopyComponents($@"{package.ContentDirectory}\newrelic");
32+
_frameworkAgentComponents.CopyComponents($@"{package.GetContentFilesDirectory("any", "net462")}\newrelic");
3233
package.CopyToLib(_frameworkAgentComponents.AgentApiDll);
34+
3335
package.CopyAll(PackageDirectory);
34-
TransformNewRelicConfig();
3536
var agentInfo = new AgentInfo
3637
{
3738
InstallType = $"NugetAzureWebsites{Platform}"
3839
};
3940

40-
agentInfo.WriteToDisk(RootDirectory);
41+
var newRelicConfigPaths = new[]
42+
{
43+
$@"{rootDirectory}\newrelic.config",
44+
$@"{StagingDirectory}\contentFiles\any\net462\newrelic\newrelic.config",
45+
};
46+
47+
foreach (var newRelicConfigPath in newRelicConfigPaths)
48+
{
49+
TransformNewRelicConfig(newRelicConfigPath);
50+
agentInfo.WriteToDisk(Path.GetDirectoryName(newRelicConfigPath));
51+
}
52+
4153
package.SetVersion(_frameworkAgentComponents.Version);
54+
4255
_nuGetPackageName = package.Pack();
4356
}
4457

45-
private void TransformNewRelicConfig()
58+
private static void TransformNewRelicConfig(string newRelicConfigPath)
4659
{
47-
var path = $@"{RootDirectory}\newrelic.config";
4860
var xml = new System.Xml.XmlDocument();
4961

5062
// Update the 'newrelic.config' file
51-
xml.Load(path);
63+
xml.Load(newRelicConfigPath);
5264
var ns = new System.Xml.XmlNamespaceManager(xml.NameTable);
5365
ns.AddNamespace("x", "urn:newrelic-config");
5466

@@ -63,7 +75,7 @@ private void TransformNewRelicConfig()
6375

6476
// Set the 'directory' attribute
6577
nodeLog.SetAttribute("directory", @"c:\Home\LogFiles\NewRelic");
66-
xml.Save(path);
78+
xml.Save(newRelicConfigPath);
6779
}
6880

6981
/// <summary>
@@ -112,6 +124,10 @@ private SortedSet<string> GetExpectedComponents(string installedFilesRoot)
112124
// content folder - framework agent
113125
AddFullAgentComponents(expectedComponents, Path.Combine(installedFilesRoot, "content", "newrelic"));
114126

127+
// contentFiles folder - all agents
128+
var contentFilesRoot = Path.Combine(installedFilesRoot, "contentFiles", "any");
129+
AddFullAgentComponents(expectedComponents, Path.Combine(contentFilesRoot, "net462", "newrelic"));
130+
115131
// lib folder - agent api
116132
ValidationHelpers.AddSingleFileToCollectionWithNewPath(expectedComponents, Path.Combine(installedFilesRoot, "lib"), _frameworkAgentComponents.AgentApiDll);
117133

@@ -132,6 +148,7 @@ private void AddFullAgentComponents(SortedSet<string> expectedComponents, string
132148
private static SortedSet<string> GetUnpackedComponents(string installedFilesRoot)
133149
{
134150
var unpackedComponents = ValidationHelpers.GetUnpackedComponents(Path.Combine(installedFilesRoot, "content"));
151+
unpackedComponents.UnionWith(ValidationHelpers.GetUnpackedComponents(Path.Combine(installedFilesRoot, "contentFiles")));
135152
unpackedComponents.UnionWith(ValidationHelpers.GetUnpackedComponents(Path.Combine(installedFilesRoot, "lib")));
136153
unpackedComponents.UnionWith(ValidationHelpers.GetUnpackedComponents(Path.Combine(installedFilesRoot, "images")));
137154
unpackedComponents.UnionWith(ValidationHelpers.GetUnpackedComponents(Path.Combine(installedFilesRoot, "tools")));

build/Packaging/NugetAzureWebSites-x64/NewRelic.Azure.WebSites.x64.nuspec

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
3-
<metadata>
3+
<metadata minClientVersion="3.3.0">
44
<id>NewRelic.Azure.WebSites.x64</id>
55
<version>REPLACE_WITH_VERSION</version>
66
<title>New Relic for Windows Azure Web Sites (x64)</title>
77
<authors>New Relic</authors>
88
<license type="expression">Apache-2.0</license>
9-
<projectUrl>https://docs.newrelic.com/docs/apm/agents/net-agent/azure-installation/install-net-agent-azure-web-apps</projectUrl>
9+
<projectUrl>https://docs.newrelic.com/install/dotnet/?deployment=azure&amp;azure=azurenugetframework</projectUrl>
1010
<repository type="git" url="https://github.com/newrelic/newrelic-dotnet-agent" />
1111
<icon>images\icon.png</icon>
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>Go to New Relic to sign up and get your license key at https://newrelic.com or you can get a license key through the Windows Azure management portal via Add-On store.</description>
1414
<summary>This package will add all of the resources needed to profile your Windows Azure Web Site running as a reserved 64-bit instance. For more information on this package visit: https://docs.newrelic.com/docs/apm/agents/net-agent/azure-installation/install-net-agent-azure-web-apps</summary>
1515
<releaseNotes>For detailed information see: https://docs.newrelic.com/docs/release-notes/agent-release-notes/net-release-notes/</releaseNotes>
16+
<contentFiles>
17+
<files include="**/newrelic/**/*.*" buildAction="None" copyToOutput="true" flatten="false" />
18+
</contentFiles>
1619
</metadata>
1720
<files>
18-
<file src="content\**" target="content" />
21+
<file src="**\newrelic\**\*" target="." />
1922
<file src="lib\**" target="lib" />
2023
<file src="tools\**" target="tools" />
2124
<file src="..\..\icon.png" target="images\" />

build/Packaging/NugetAzureWebSites-x86/NewRelic.Azure.WebSites.nuspec

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
3-
<metadata>
3+
<metadata minClientVersion="3.3.0">
44
<id>NewRelic.Azure.WebSites</id>
55
<version>REPLACE_WITH_VERSION</version>
66
<title>New Relic for Windows Azure Web Sites (x86)</title>
77
<authors>New Relic</authors>
88
<license type="expression">Apache-2.0</license>
9-
<projectUrl>https://docs.newrelic.com/docs/apm/agents/net-agent/azure-installation/install-net-agent-azure-web-apps</projectUrl>
9+
<projectUrl>https://docs.newrelic.com/install/dotnet/?deployment=azure&amp;azure=azurenugetframework</projectUrl>
1010
<repository type="git" url="https://github.com/newrelic/newrelic-dotnet-agent" />
1111
<icon>images\icon.png</icon>
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>Go to New Relic to sign up and get your license key at https://newrelic.com or you can get a license key through the Windows Azure management portal via Add-On store.</description>
1414
<summary>This package will add all of the resources needed to profile your Windows Azure Web Site. For more information on this package visit: https://docs.newrelic.com/docs/apm/agents/net-agent/azure-installation/install-net-agent-azure-web-apps</summary>
1515
<releaseNotes>For detailed information see: https://docs.newrelic.com/docs/release-notes/agent-release-notes/net-release-notes/</releaseNotes>
16+
<contentFiles>
17+
<files include="**/newrelic/**/*.*" buildAction="None" copyToOutput="true" flatten="false" />
18+
</contentFiles>
1619
</metadata>
1720
<files>
18-
<file src="content\**" target="content" />
21+
<file src="**\newrelic\**\*" target="." />
1922
<file src="lib\**" target="lib" />
2023
<file src="tools\**" target="tools" />
2124
<file src="..\..\icon.png" target="images\" />

0 commit comments

Comments
 (0)