-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathGetFrameworkPath.cs
150 lines (126 loc) · 6.65 KB
/
GetFrameworkPath.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
#nullable disable
namespace Microsoft.Build.Tasks
{
/// <summary>
/// Returns the paths to the various frameworks versions.
/// </summary>
public class GetFrameworkPath : TaskExtension
{
#region ITask Members
/// <summary>
/// Does nothing: getters do all the work
/// </summary>
public override bool Execute()
{
return true;
}
#endregion
#region Properties
// PERF NOTE: We cache these values in statics -- although the code we call does this too,
// it still seems to give an advantage perhaps because there is one less string copy.
// In a large build, this adds up.
// PERF NOTE: We also only find paths we are actually asked for (via <Output> tags)
private static readonly Lazy<string> s_path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Latest));
private static readonly Lazy<string> s_version11Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version11));
private static readonly Lazy<string> s_version20Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version20));
private static readonly Lazy<string> s_version30Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version30));
private static readonly Lazy<string> s_version35Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version35));
private static readonly Lazy<string> s_version40Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version40));
private static readonly Lazy<string> s_version45Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version45));
private static readonly Lazy<string> s_version451Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version451));
private static readonly Lazy<string> s_version452Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version452));
private static readonly Lazy<string> s_version46Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version46));
private static readonly Lazy<string> s_version461Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version461));
private static readonly Lazy<string> s_version462Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version462));
private static readonly Lazy<string> s_version47Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version47));
private static readonly Lazy<string> s_version471Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version471));
private static readonly Lazy<string> s_version472Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version472));
private static readonly Lazy<string> s_version48Path = new Lazy<string>(() => ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version48));
/// <summary>
/// Path to the latest framework, whatever version it happens to be
/// </summary>
[Output]
public string Path => s_path.Value;
/// <summary>
/// Path to the v1.1 framework, if available
/// </summary>
[Output]
public string FrameworkVersion11Path => s_version11Path.Value;
/// <summary>
/// Path to the v2.0 framework, if available
/// </summary>
[Output]
public string FrameworkVersion20Path => s_version20Path.Value;
/// <summary>
/// Path to the v3.0 framework, if available
/// </summary>
[Output]
public string FrameworkVersion30Path => s_version30Path.Value;
/// <summary>
/// Path to the v3.5 framework, if available
/// </summary>
[Output]
public string FrameworkVersion35Path => s_version35Path.Value;
/// <summary>
/// Path to the v4.0 framework, if available
/// </summary>
[Output]
public string FrameworkVersion40Path => s_version40Path.Value;
/// <summary>
/// Path to the v4.5 framework, if available
/// </summary>
[Output]
public string FrameworkVersion45Path => s_version45Path.Value;
/// <summary>
/// Path to the v4.5.1 framework, if available
/// </summary>
[Output]
public string FrameworkVersion451Path => s_version451Path.Value;
/// <summary>
/// Path to the v4.5.2 framework, if available
/// </summary>
[Output]
public string FrameworkVersion452Path => s_version452Path.Value;
/// <summary>
/// Path to the v4.6 framework, if available
/// </summary>
[Output]
public string FrameworkVersion46Path => s_version46Path.Value;
/// <summary>
/// Path to the v4.6.1 framework, if available
/// </summary>
[Output]
public string FrameworkVersion461Path => s_version461Path.Value;
/// <summary>
/// Path to the v4.6.2 framework, if available
/// </summary>
[Output]
public string FrameworkVersion462Path => s_version462Path.Value;
/// <summary>
/// Path to the v4.7 framework, if available
/// </summary>
[Output]
public string FrameworkVersion47Path => s_version47Path.Value;
/// <summary>
/// Path to the v4.7.1 framework, if available
/// </summary>
[Output]
public string FrameworkVersion471Path => s_version471Path.Value;
/// <summary>
/// Path to the v4.7.2 framework, if available
/// </summary>
[Output]
public string FrameworkVersion472Path => s_version472Path.Value;
/// <summary>
/// Path to the v4.8 framework, if available
/// </summary>
[Output]
public string FrameworkVersion48Path => s_version48Path.Value;
#endregion
}
}