Skip to content

Commit ee04d25

Browse files
authored
fix: In-process Azure Function publishes Nuget agent DLLs to the wrong folder (#3068)
1 parent c8acbc5 commit ee04d25

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

build/ArtifactBuilder/Artifacts/NugetAgent.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ public class NugetAgent : Artifact
1313
private readonly AgentComponents _coreAgentX86Components;
1414
private string _nuGetPackageName;
1515

16-
public NugetAgent(string configuration)
16+
public NugetAgent(string configuration, string versionOverride = null)
1717
: base(nameof(NugetAgent))
1818
{
1919
Configuration = configuration;
20+
VersionOverride = versionOverride;
2021
ValidateContentAction = ValidateContent;
2122

2223
_frameworkAgentComponents = AgentComponents.GetAgentComponents(AgentType.Framework, Configuration, "x64", RepoRootDirectory, HomeRootDirectory);
@@ -27,6 +28,7 @@ public NugetAgent(string configuration)
2728
}
2829

2930
public string Configuration { get; }
31+
public string VersionOverride { get; }
3032

3133
protected override void InternalBuild()
3234
{
@@ -75,7 +77,7 @@ protected override void InternalBuild()
7577
agentInfo.WriteToDisk(Path.GetDirectoryName(newRelicConfigPath));
7678
}
7779

78-
package.SetVersion(_frameworkAgentComponents.Version);
80+
package.SetVersion(VersionOverride ?? _frameworkAgentComponents.Version);
7981

8082
_nuGetPackageName = package.Pack();
8183
}

build/ArtifactBuilder/Program.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ private static void BuildMsiInstaller(string[] args)
8383
private static void BuildNugetAgent(string[] args)
8484
{
8585
var configuration = args[1];
86-
var c = new NugetAgent(configuration);
86+
string versionOverride = null;
87+
if (args.Length > 2)
88+
versionOverride = args[2];
89+
var c = new NugetAgent(configuration, versionOverride);
8790
c.Build();
8891
}
8992

build/Packaging/NugetAgent/NewRelic.Agent.nuspec

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<files>
2121
<file src="**\newrelic\**\*" target="." />
2222
<file src="tools\**" target="tools" />
23+
<file src="build\**" target="build" />
2324
<file src="README.md" target="." />
2425
<file src="..\..\icon.png" target="images\" />
2526
</files>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
Copyright 2020 New Relic Corporation. All rights reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
-->
5+
6+
<!-- This MSBuild target file is used during publish of an Azure In-Process function
7+
to move the NewRelic .NET agent assemblies back to the root of the publish directory
8+
after the _GenerateFunctionsAndCopyContentFiles task blindly moves all .DLLs to the bin folder.
9+
This target applies to Azure Function In-Process apps only -->
10+
<Project ToolsVersion="14.0"
11+
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12+
<Target Name="MoveNewRelicFiles"
13+
AfterTargets="_GenerateFunctionsAndCopyContentFiles"
14+
Condition="Exists('$(PublishDir)bin\newrelic\')">
15+
<ItemGroup>
16+
<NewRelicAgentAssemblies Include="$(PublishDir)bin\newrelic\**\*"/>
17+
</ItemGroup>
18+
<Move SourceFiles="@(NewRelicAgentAssemblies)"
19+
DestinationFiles="$(PublishDir)newrelic\%(RecursiveDir)%(Filename)%(Extension)"
20+
OverwriteReadOnlyFiles="true" />
21+
<RemoveDir Directories="$(PublishDir)bin\newrelic\"
22+
Condition="Exists('$(PublishDir)bin\newrelic\')" />
23+
<Message Importance="high" Text="Moved NewRelic agent assemblies to $(PublishDir)newrelic\"/>
24+
</Target>
25+
</Project>

0 commit comments

Comments
 (0)