Skip to content

Commit f1c70a0

Browse files
committed
Remove BUILDING_PROTO #ifdefs when building proto ensure that FX_ATLEAST_45 is not set
1 parent 4952102 commit f1c70a0

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

src/FSharpSource.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<PropertyGroup Condition="'$(TargetFramework)'=='net20'">
104104
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
105105
<DefineConstants>$(DefineConstants);FSHARP_CORE_2_0</DefineConstants>
106-
<DefineConstants>$(DefineConstants);RUNTIME</DefineConstants>
106+
<DefineConstants>$(DefineConstants);RUNTIME</DefineConstants>
107107
<DefineConstants>$(DefineConstants);FX_ATLEAST_35</DefineConstants>
108108
<DefineConstants>$(DefineConstants);FX_NO_STRUCTURAL_EQUALITY</DefineConstants>
109109
<DefineConstants>$(DefineConstants);FX_NO_CANCELLATIONTOKEN_CLASSES</DefineConstants>
@@ -123,7 +123,7 @@
123123
<PropertyGroup Condition="'$(TargetFramework)'=='net40'">
124124
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
125125
<DefineConstants>$(DefineConstants);FSHARP_CORE_4_5</DefineConstants>
126-
<DefineConstants>$(DefineConstants);FX_ATLEAST_45</DefineConstants>
126+
<DefineConstants Condition="'$(Configuration)'!='Proto'">$(DefineConstants);FX_ATLEAST_45</DefineConstants>
127127
<DefineConstants>$(DefineConstants);FX_ATLEAST_40</DefineConstants>
128128
<DefineConstants>$(DefineConstants);FX_ATLEAST_35</DefineConstants>
129129
<DefineConstants>$(DefineConstants);BE_SECURITY_TRANSPARENT</DefineConstants>

src/fsharp/ReferenceResolution.fs

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,13 @@ module internal MSBuildResolver =
9191
let private Net40 = "v4.0"
9292
[<Literal>]
9393
let private Net45 = "v4.5"
94-
#if BUILDING_PROTO
95-
#else
9694
[<Literal>]
9795
let private Net451 = "v4.5.1"
98-
#endif
9996

100-
#if BUILDING_PROTO
101-
let SupportedNetFrameworkVersions = set [ Net20; Net30; Net35; Net40; Net45; (*SL only*) "v5.0" ]
102-
#else
10397
let SupportedNetFrameworkVersions = set [ Net20; Net30; Net35; Net40; Net45; Net451; (*SL only*) "v5.0" ]
104-
#endif
105-
let GetPathToDotNetFramework(v) =
98+
10699
#if FX_ATLEAST_45
100+
let GetPathToDotNetFramework(v) =
107101
let v =
108102
match v with
109103
| Net11 -> Some TargetDotNetFrameworkVersion.Version11
@@ -112,10 +106,7 @@ module internal MSBuildResolver =
112106
| Net35 -> Some TargetDotNetFrameworkVersion.Version35
113107
| Net40 -> Some TargetDotNetFrameworkVersion.Version40
114108
| Net45 -> Some TargetDotNetFrameworkVersion.Version45
115-
#if BUILDING_PROTO
116-
#else
117109
| Net451 -> Some TargetDotNetFrameworkVersion.Version451
118-
#endif
119110
| _ -> assert false; None
120111
match v with
121112
| Some v ->
@@ -124,21 +115,19 @@ module internal MSBuildResolver =
124115
| x -> [x]
125116
| _ -> []
126117
#else
118+
let GetPathToDotNetFramework(_) =
127119
// FX_ATLEAST_45 is not defined for step when we build compiler with proto compiler.
128120
[]
129121
#endif
130122

131-
let DeriveTargetFrameworkDirectoriesFor40Plus(version) =
132123
#if FX_ATLEAST_45
124+
let DeriveTargetFrameworkDirectoriesFor40Plus(version) =
133125
// starting with .Net 4.0, the runtime dirs (WindowsFramework) are never used by MSBuild RAR
134126
let v =
135127
match version with
136128
| Net40 -> Some TargetDotNetFrameworkVersion.Version40
137129
| Net45 -> Some TargetDotNetFrameworkVersion.Version45
138-
#if BUILDING_PROTO
139-
#else
140130
| Net451 -> Some TargetDotNetFrameworkVersion.Version451
141-
#endif
142131
| _ -> assert false; None // unknown version - some parts in the code are not synced
143132
match v with
144133
| Some v ->
@@ -147,21 +136,18 @@ module internal MSBuildResolver =
147136
| x -> [x]
148137
| None -> []
149138
#else
139+
let DeriveTargetFrameworkDirectoriesFor40Plus(_) =
150140
// FX_ATLEAST_45 is not defined for step when we build compiler with proto compiler.
151141
[]
152142
#endif
153143

154144
/// Determine the default "frameworkVersion" (which is passed into MSBuild resolve).
155145
/// This code uses MSBuild to determine version of the highest installed framework.
156146
let HighestInstalledNetFrameworkVersionMajorMinor() =
157-
#if FX_ATLEAST_45
158-
#if BUILDING_PROTO
159-
#else
160-
if box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version451)) <> null then 4, Net451
161-
else
162-
#endif
163-
if box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version45)) <> null then 4, Net45
164-
else 4, Net40 // version is 4.0 assumed since this code is running.
147+
#if FX_ATLEAST_45
148+
if box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version451)) <> null then 4, Net451
149+
elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version45)) <> null then 4, Net45
150+
else 4, Net40 // version is 4.0 assumed since this code is running.
165151
#else
166152
// FX_ATLEAST_45 is not defined is required for step when we build compiler with proto compiler and this branch should not be hit
167153
4, Net40

0 commit comments

Comments
 (0)