Skip to content

Commit db411cf

Browse files
committed
including RuntimeIdentifier when building extensions
1 parent c740418 commit db411cf

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

src/WebJobs.Script/BindingExtensions/ExtensionsManager.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
using System.Collections;
66
using System.Collections.Generic;
77
using System.Diagnostics;
8-
using System.Globalization;
98
using System.IO;
109
using System.Linq;
10+
using System.Runtime.InteropServices;
1111
using System.Text;
1212
using System.Threading.Tasks;
1313
using System.Xml;
@@ -106,6 +106,7 @@ internal virtual Task ProcessExtensionsProject(string projectFolder)
106106

107107
try
108108
{
109+
string runtimeIdentifierParameter = GetRuntimeIdentifierParameter();
109110
var startInfo = new ProcessStartInfo
110111
{
111112
FileName = dotnetPath,
@@ -115,7 +116,7 @@ internal virtual Task ProcessExtensionsProject(string projectFolder)
115116
UseShellExecute = false,
116117
ErrorDialog = false,
117118
WorkingDirectory = projectFolder,
118-
Arguments = $"build \"{ExtensionsProjectFileName}\" -o bin --force --no-incremental"
119+
Arguments = $"build \"{ExtensionsProjectFileName}\" -o bin --force --no-incremental {runtimeIdentifierParameter}"
119120
};
120121

121122
string nugetPath = Path.Combine(Path.GetDirectoryName(ProjectPath), "nuget.config");
@@ -232,14 +233,41 @@ private ProjectRootElement CreateDefaultProject(string path)
232233
var root = ProjectRootElement.Create(path, NewProjectFileOptions.None);
233234
root.Sdk = "Microsoft.NET.Sdk";
234235

235-
root.AddPropertyGroup()
236-
.AddProperty("TargetFramework", "netstandard2.0");
236+
var propGroup = root.AddPropertyGroup();
237+
propGroup.AddProperty("TargetFramework", "netstandard2.0");
238+
propGroup.AddProperty("WarningsAsErrors", string.Empty);
237239

238240
root.AddItemGroup()
239241
.AddItem(PackageReferenceElementName, ExtensionsPackageId)
240242
.AddMetadata(PackageReferenceVersionElementName, "1.0.0-beta2", true);
241243

242244
return root;
243245
}
246+
247+
private static string GetRuntimeIdentifierParameter()
248+
{
249+
string os = null;
250+
251+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
252+
{
253+
os = "win";
254+
}
255+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
256+
{
257+
os = "osx";
258+
}
259+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
260+
{
261+
os = "linux";
262+
}
263+
else
264+
{
265+
return string.Empty;
266+
}
267+
268+
string arch = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
269+
270+
return $"-r {os}-{arch}";
271+
}
244272
}
245273
}

0 commit comments

Comments
 (0)