forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetGeneratedAppConfigMetadata.cs
48 lines (41 loc) · 1.56 KB
/
SetGeneratedAppConfigMetadata.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
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.NET.Build.Tasks
{
public sealed class SetGeneratedAppConfigMetadata : TaskBase
{
/// <summary>
/// Path to the app.config source file.
/// </summary>
public ITaskItem AppConfigFile { get; set; }
/// <summary>
/// Path to the app.config generated source file.
/// </summary>
[Required]
public string GeneratedAppConfigFile { get; set; }
/// <summary>
/// Name of the output application config file: $(TargetFileName).config
/// </summary>
[Required]
public string TargetName { get; set; }
/// <summary>
/// Path to an intermediate file where we can write the input app.config plus the generated startup supportedRuntime with metadata
/// </summary>
[Output]
public ITaskItem OutputAppConfigFileWithMetadata { get; set; }
protected override void ExecuteCore()
{
OutputAppConfigFileWithMetadata = new TaskItem(GeneratedAppConfigFile);
if (AppConfigFile != null)
{
AppConfigFile.CopyMetadataTo(OutputAppConfigFileWithMetadata);
}
else
{
OutputAppConfigFileWithMetadata.SetMetadata(MetadataKeys.TargetPath, TargetName);
}
}
}
}