Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1bc99dc

Browse files
committed
Ensures that when the F# project system updates the app.config file for the project. It correctly handles the binding redirects.1. If autogeneratebindingredirects is set in the project then the project system leaves it to the build.2. For projects without autogeneratebindingredirects it adds a bindingredirect for fsharp.core for each possible version of fsharp.core, depending on the target framework
1 parent220c17d commit1bc99dc

File tree

6 files changed

+102
-103
lines changed

6 files changed

+102
-103
lines changed

‎vsintegration/src/deployment/EnableOpenSource/EnableOpenSource.csproj‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@
2929
</PropertyGroup>
3030
<PropertyGroupCondition="'$(Configuration)' == 'VSRelease'">
3131
<DeployExtensionCondition="'$(AppVeyor)' != ''">False</DeployExtension>
32+
<DeployExtensionCondition="'$(AppVeyor)' == ''">True</DeployExtension>
3233
</PropertyGroup>
3334
<PropertyGroupCondition="'$(Configuration)' == 'Debug'">
3435
<DeployExtensionCondition="'$(AppVeyor)' != ''">False</DeployExtension>
3536
</PropertyGroup>
37+
<PropertyGroupCondition="'$(Configuration)' == 'VSDebug'">
38+
<DeployExtensionCondition="'$(AppVeyor)' != ''">False</DeployExtension>
39+
<DeployExtensionCondition="'$(AppVeyor)' == ''">True</DeployExtension>
40+
</PropertyGroup>
3641
<ImportProject="..\..\FSharp.Common.props" />
3742
<PropertyGroup>
3843
<SchemaVersion>2.0</SchemaVersion>

‎vsintegration/src/unittests/Tests.ProjectSystem.MultiTargeting.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ type MultiTargeting() =
154154
let refLibPath = this.prepTest(projFile)
155155
use project = TheTests.CreateProject(projFile, "true", ccn, sp)
156156
let fn = new System.Runtime.Versioning.FrameworkName(".NETFramework", new System.Version(4, 0))
157-
project.FixupAppConfigOnTargetFXChange(fn.ToString()) |> ignore
157+
project.FixupAppConfigOnTargetFXChange(fn.ToString(), "4.3.0.0", false) |> ignore
158158
let appFile = Path.Combine((Path.GetDirectoryName projFile), "app.config")
159159
let appText = System.IO.File.ReadAllText(appFile)
160160
Assert.IsTrue(appText.Contains("<supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.0\" />"))

‎vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/HierarchyNode.cs‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3276,7 +3276,6 @@ internal static string GetFrameworkVersionString(System.Runtime.Versioning.Frame
32763276

32773277
// This is called back from IVsTrackProjectRetargeting::OnSetTargetFramework
32783278
// to actually set the target framework.
3279-
32803279
publicintUpdateTargetFramework(
32813280
IVsHierarchyhier,
32823281
stringcurrentTargetFrameworkMoniker,
@@ -3301,6 +3300,10 @@ string newTargetFrameworkMoniker
33013300
projectMgr.BuildProject.SetProperty(ProjectFileConstants.TargetFrameworkVersion,HierarchyNode.GetFrameworkVersionString(frameworkName));
33023301
projectMgr.BuildProject.SetProperty(ProjectFileConstants.TargetFrameworkProfile,frameworkName.Profile);
33033302

3303+
stringtargetFSharpCoreVersion=projectMgr.BuildProject.GetPropertyValue(ProjectFileConstants.TargetFSharpCoreVersion);
3304+
boolautoGenerateBindingRedirects;
3305+
bool.TryParse(projectMgr.BuildProject.GetPropertyValue("AutoGenerateBindingRedirects"),outautoGenerateBindingRedirects);
3306+
33043307
#ifFX_ATLEAST_45
33053308
// update FSharp.Core only if we are addressing '.NETFramework' as opposed to e.g. Silverlight or Portable
33063309
if(frameworkName.Identifier==".NETFramework")
@@ -3316,20 +3319,8 @@ string newTargetFrameworkMoniker
33163319
if(hasIncompatibleFsCore)
33173320
{
33183321
varnewVersion=
3319-
frameworkName.Version.Major>=4
3320-
?
3321-
#ifFX_ATLEAST_45
3322-
(frameworkName.Version.Minor<5?newVersion(4,3,0,0):newVersion(4,4,0,0))
3323-
#else
3324-
newVersion(4,0,0,0)
3325-
#endif
3326-
:
3327-
#ifFX_ATLEAST_45
3328-
newVersion(2,3,0,0)
3329-
#else
3330-
newVersion(2,0,0,0)
3331-
#endif
3332-
;
3322+
frameworkName.Version.Major>=4?
3323+
(frameworkName.Version.Minor<5?newVersion(4,3,0,0):newVersion(4,4,0,0)):newVersion(2,3,0,0);
33333324

33343325
if(projectMgr.CanUseTargetFSharpCoreReference)
33353326
{
@@ -3368,13 +3359,14 @@ string newTargetFrameworkMoniker
33683359
});
33693360
}
33703361
}
3362+
targetFSharpCoreVersion=newVersion.ToString();
33713363
}
33723364
}
33733365
#endif
33743366

33753367
try
33763368
{
3377-
this.projectMgr.FixupAppConfigOnTargetFXChange(newTargetFrameworkMoniker);
3369+
this.projectMgr.FixupAppConfigOnTargetFXChange(newTargetFrameworkMoniker,targetFSharpCoreVersion,autoGenerateBindingRedirects);
33783370
}
33793371
catch(Exceptione)
33803372
{

‎vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectNode.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3347,7 +3347,7 @@ internal virtual void SetBuildConfigurationProperties(ConfigCanonicalName config
33473347

33483348
publicabstractvoidComputeSourcesAndFlags();
33493349

3350-
internalabstractintFixupAppConfigOnTargetFXChange(stringnewTargetFramework);
3350+
internalabstractintFixupAppConfigOnTargetFXChange(stringnewTargetFramework,stringtargetFSharpCoreVersion,boolautoGenerateBindingRedirects);
33513351

33523352
/// <summary>
33533353
/// This execute an MSBuild target.

‎vsintegration/src/vs/FsPkgs/FSharp.Project/FS/AppConfigHelper.fs‎

Lines changed: 78 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -317,92 +317,94 @@ namespace Microsoft.VisualStudio.FSharp.ProjectSystem
317317
if dirtythen isDirty<- dirty
318318

319319
/// Updates list of binding redirects to the config file. Content of list is governed by the major version of target framework.
320-
/// Current redirects: 2.0 -> "2.0.0.0" to "2.3.0.0". 4.0 or greater - "2.0.0.0" to "4.3.0.0", "2.3.5.0" to "4.3.0.0", "4.0.0.0" to "4.3.0.0"
321-
memberx.EnsureHasBindingRedirects(majorVersion)=
320+
memberx.EnsureHasBindingRedirects(majorVersion,minorVersion,targetFSharpCoreVersion,autoGenerateBindingRedirects)=
322321

323-
// some helpers to simplify work with XLinq
324-
letxname= System.Xml.Linq.XName.Get
325-
letxnameAsmV1 name= xname("{urn:schemas-microsoft-com:asm.v1}"+ name)
322+
ifnot autoGenerateBindingRedirectsthen
323+
// some helpers to simplify work with XLinq
324+
letxname= System.Xml.Linq.XName.Get
325+
letxnameAsmV1 name= xname("{urn:schemas-microsoft-com:asm.v1}"+ name)
326326

327-
letfsCoreAttributes=
328-
[
329-
xname"name","FSharp.Core"
330-
xname"publicKeyToken", Microsoft.VisualStudio.FSharp.ProjectSystem.Utilities.FsCorePublicKeyToken
331-
xname"culture","neutral"
332-
]
333-
334-
// depending on major version of target framework we need to populate corresponding binding redirects in config
335-
letredirects=
336-
if majorVersion>=4then
337-
[
338-
"2.0.0.0","4.3.0.0"
339-
"2.3.5.0","4.3.0.0"
340-
"4.0.0.0","4.3.0.0"
341-
]
342-
else
327+
letfsCoreAttributes=
343328
[
344-
"2.0.0.0","2.3.0.0"
329+
xname"name","FSharp.Core"
330+
xname"publicKeyToken", Microsoft.VisualStudio.FSharp.ProjectSystem.Utilities.FsCorePublicKeyToken
331+
xname"culture","neutral"
345332
]
346333

347-
letOldVersion="oldVersion"
348-
letNewVersion="newVersion"
349-
letBindingRedirect="bindingRedirect"
350-
letDependentAssembly="dependentAssembly"
351-
letAssemblyIdentity="assemblyIdentity"
334+
// depending on major version of target framework we need to populate corresponding binding redirects in config
335+
letredirects=
336+
if majorVersion>=4then
337+
[
338+
"2.0.0.0", targetFSharpCoreVersion
339+
"2.3.5.0", targetFSharpCoreVersion
340+
"4.0.0.0", targetFSharpCoreVersion
341+
]@if minorVersion>=5&& targetFSharpCoreVersion<>"4.3.1.0"then
342+
["4.3.1.0", targetFSharpCoreVersion]
343+
else
344+
[]
345+
else
346+
[
347+
"2.0.0.0","2.3.0.0"
348+
]
352349

353-
letcreate(p:System.Xml.Linq.XElement)name attrs=
354-
letel=new System.Xml.Linq.XElement(name: System.Xml.Linq.XName)
355-
p.Add(el)
356-
for(name, value)in attrsdo
357-
letattr=new System.Xml.Linq.XAttribute(name, value)
358-
el.Add(attr)
359-
el
350+
letOldVersion="oldVersion"
351+
letNewVersion="newVersion"
352+
letBindingRedirect="bindingRedirect"
353+
letDependentAssembly="dependentAssembly"
354+
letAssemblyIdentity="assemblyIdentity"
360355

361-
letcreateRedirect p(oldVersion,newVersion)=
362-
create p(xnameAsmV1 BindingRedirect)[xname OldVersion, oldVersion; xname NewVersion, newVersion]
363-
|> ignore
356+
letcreate(p:System.Xml.Linq.XElement)name attrs=
357+
letel=new System.Xml.Linq.XElement(name: System.Xml.Linq.XName)
358+
p.Add(el)
359+
for(name, value)in attrsdo
360+
letattr=new System.Xml.Linq.XAttribute(name, value)
361+
el.Add(attr)
362+
el
364363

365-
letgetOrCreate(p:System.Xml.Linq.XElement)name=
366-
match p.Element(name)with
367-
|null-> create p name[]
368-
| el-> el
369-
370-
letdocument= fileHolder.GetXml()
371-
letruntime= getOrCreate document.Root(xname"runtime")
372-
letassemblyBinding= getOrCreate runtime(xnameAsmV1"assemblyBinding")
364+
letcreateRedirect p(oldVersion,newVersion)=
365+
create p(xnameAsmV1 BindingRedirect)[xname OldVersion, oldVersion; xname NewVersion, newVersion]|> ignore
373366

374-
// find dependentAssembly node with attributes that corresponds to the FSharp.Core
375-
letfsharpCoreDependentAssemblyElement=
376-
letn=
377-
assemblyBinding.Elements(xnameAsmV1 DependentAssembly)
378-
|> Seq.tryFind(
379-
fun da->
380-
match da.Element(xnameAsmV1 AssemblyIdentity)with
381-
|null->false
382-
| x->
383-
fsCoreAttributes
384-
|> Seq.forall(
385-
fun(attr,value)->
386-
match x.Attribute attrwith
387-
|null->false
388-
| v-> v.Value= value
389-
)
390-
)
391-
match nwith
392-
| Some el->
393-
// drop existing redirects for FSharp.Core
394-
letexistingRedirects= el.Elements(xnameAsmV1 BindingRedirect)|> List.ofSeq
395-
for existingRedirectin existingRedirectsdo
396-
existingRedirect.Remove()
397-
el
398-
| None->
399-
letdependentAssembly= create assemblyBinding(xnameAsmV1 DependentAssembly)[]
400-
let_fsCoreIdentity= create dependentAssembly(xnameAsmV1 AssemblyIdentity) fsCoreAttributes
401-
dependentAssembly
367+
letgetOrCreate(p:System.Xml.Linq.XElement)name=
368+
match p.Element(name)with
369+
|null-> create p name[]
370+
| el-> el
371+
372+
letdocument= fileHolder.GetXml()
373+
letruntime= getOrCreate document.Root(xname"runtime")
374+
letassemblyBinding= getOrCreate runtime(xnameAsmV1"assemblyBinding")
375+
376+
// find dependentAssembly node with attributes that corresponds to the FSharp.Core
377+
letfsharpCoreDependentAssemblyElement=
378+
letn=
379+
assemblyBinding.Elements(xnameAsmV1 DependentAssembly)
380+
|> Seq.tryFind(
381+
fun da->
382+
match da.Element(xnameAsmV1 AssemblyIdentity)with
383+
|null->false
384+
| x->
385+
fsCoreAttributes
386+
|> Seq.forall(
387+
fun(attr,value)->
388+
match x.Attribute attrwith
389+
|null->false
390+
| v-> v.Value= value
391+
)
392+
)
393+
match nwith
394+
| Some el->
395+
// drop existing redirects for FSharp.Core
396+
letexistingRedirects= el.Elements(xnameAsmV1 BindingRedirect)|> List.ofSeq
397+
for existingRedirectin existingRedirectsdo
398+
existingRedirect.Remove()
399+
el
400+
| None->
401+
letdependentAssembly= create assemblyBinding(xnameAsmV1 DependentAssembly)[]
402+
let_fsCoreIdentity= create dependentAssembly(xnameAsmV1 AssemblyIdentity) fsCoreAttributes
403+
dependentAssembly
404+
405+
for redirectin redirectsdo
406+
createRedirect fsharpCoreDependentAssemblyElement redirect
402407

403-
for redirectin redirectsdo
404-
createRedirect fsharpCoreDependentAssemblyElement redirect
405-
406408
memberx.IsDirty()= isDirty
407409

408410
memberx.Save()=

‎vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g.
813813
if(AssemblyReferenceNode.IsFSharpCoreReference asmNode)then
814814
asmNode.RebindFSharpCoreAfterUpdatingVersion(buildResult)
815815

816+
this.UpdateTargetFramework(this.InteropSafeIVsHierarchy, this.GetTargetFrameworkMoniker(), this.GetTargetFrameworkMoniker())|> ignore
816817
this.ComputeSourcesAndFlags()
817818

818819
overridethis.SendReferencesToFSI(references)=
@@ -1845,7 +1846,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g.
18451846

18461847
(frameworkName, runtime,if String.IsNullOrEmpty(sku)thennullelse sku)
18471848

1848-
memberinternalx.DoFixupAppConfigOnTargetFXChange(frameworkName:System.Runtime.Versioning.FrameworkName,runtime:string,sku:string)=
1849+
memberinternalx.DoFixupAppConfigOnTargetFXChange(frameworkName:System.Runtime.Versioning.FrameworkName,runtime:string,sku:string,targetFSharpCoreVersion:string,autoGenerateBindingRedirects:bool)=
18491850
let mutableres= VSConstants.E_FAIL
18501851
letspecialFiles= x:> IVsProjectSpecialFiles
18511852
// We only want to force-generate an AppConfig file if the output type is EXE;
@@ -1865,12 +1866,11 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g.
18651866
res<- langConfigFile.Open(x)
18661867
if ErrorHandler.Succeeded(res)then
18671868
langConfigFile.EnsureSupportedRuntimeElement(runtime, sku)
1868-
if langConfigFile.IsDirty()then
1869-
letnode= x.NodeFromItemId(itemid)
1870-
System.Diagnostics.Debug.Assert(node<>null,"No project node for the item?")
1871-
if node<>nullthen
1872-
langConfigFile.EnsureHasBindingRedirects(frameworkName.Version.Major)
1873-
res<- langConfigFile.Save()
1869+
letnode= x.NodeFromItemId(itemid)
1870+
System.Diagnostics.Debug.Assert(node<>null,"No project node for the item?")
1871+
if node<>nullthen
1872+
langConfigFile.EnsureHasBindingRedirects(frameworkName.Version.Major, frameworkName.Version.Minor,targetFSharpCoreVersion, autoGenerateBindingRedirects)
1873+
res<- langConfigFile.Save()
18741874

18751875
// if we couldn't find the file, but we don't need it, then just ignore
18761876
if projProp.OutputType= OutputType.Library&& res= NativeMethods.STG_E_FILENOTFOUNDthen
@@ -1879,12 +1879,12 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g.
18791879
(langConfigFile:> IDisposable).Dispose()
18801880
res
18811881

1882-
overridex.FixupAppConfigOnTargetFXChange(targetFrameworkMoniker)=
1882+
overridex.FixupAppConfigOnTargetFXChange(targetFrameworkMoniker,targetFSharpCoreVersion,autoGenerateBindingRedirects)=
18831883
letframeworkName=new System.Runtime.Versioning.FrameworkName(targetFrameworkMoniker)
18841884
// Spec says to do this only if the framework family is ".NETFramework"
18851885
if String.Compare(frameworkName.Identifier,".NETFramework",true, CultureInfo.InvariantCulture)=0then
18861886
let(frameworkName,runtime,sku)= x.DetermineRuntimeAndSKU(targetFrameworkMoniker)
1887-
x.DoFixupAppConfigOnTargetFXChange(frameworkName, runtime, sku)
1887+
x.DoFixupAppConfigOnTargetFXChange(frameworkName, runtime, sku, targetFSharpCoreVersion, autoGenerateBindingRedirects)
18881888
else
18891889
VSConstants.S_OK
18901890

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp