forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetEmbeddedApphostPaths.cs
53 lines (44 loc) · 1.9 KB
/
GetEmbeddedApphostPaths.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.NET.Build.Tasks
{
public sealed class GetEmbeddedApphostPaths : TaskBase
{
/// <summary>
/// The command name of the dotnet tool.
/// </summary>
[Required]
public string ToolCommandName { get; set; }
[Required]
public string PackagedShimOutputDirectory { get; set; }
/// <summary>
/// The RuntimeIdentifiers that shims will be generated for.
/// </summary>
[Required]
public ITaskItem[] ShimRuntimeIdentifiers { get; set; }
/// <summary>
/// Path of generated shims. metadata "ShimRuntimeIdentifier" is used to map back to input ShimRuntimeIdentifiers.
/// </summary>
[Output]
public ITaskItem[] EmbeddedApphostPaths { get; private set; }
protected override void ExecuteCore()
{
var embeddedApphostPaths = new List<ITaskItem>();
foreach (var runtimeIdentifier in ShimRuntimeIdentifiers.Select(r => r.ItemSpec))
{
var packagedShimOutputDirectoryAndRid = Path.Combine(
PackagedShimOutputDirectory,
runtimeIdentifier);
var appHostDestinationFilePath = Path.Combine(
packagedShimOutputDirectoryAndRid,
ToolCommandName + ExecutableExtension.ForRuntimeIdentifier(runtimeIdentifier));
var item = new TaskItem(appHostDestinationFilePath);
item.SetMetadata(MetadataKeys.ShimRuntimeIdentifier, runtimeIdentifier);
embeddedApphostPaths.Add(item);
}
EmbeddedApphostPaths = embeddedApphostPaths.ToArray();
}
}
}