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

Commit709c760

Browse files
KevinRansomlatkin
authored andcommitted
Fixesdotnet#283 - Changing target framework causes incorrect binding redirects to be added to app.config
closesdotnet#308commit 36cc632283c3eea9db6b0a5c1f0063d6c045485dAuthor: latkin <latkin@microsoft.com>Date: Wed Mar 25 16:07:18 2015 -0700 Add 2.3.0.0 redirect when targeting 4.3.0.0+commit0826f7aAuthor: KevinRansom <kevinr@microsoft.com>Date: Wed Mar 25 11:04:04 2015 -0700 Handle feedback, fix some potential redirectscommitbda4c09Author: KevinRansom <kevinr@microsoft.com>Date: Wed Mar 18 15:54:38 2015 -0700 Address feedbackcommit7396db7Author: KevinRansom <kevinr@microsoft.com>Date: Wed Mar 18 12:49:30 2015 -0700Fixesdotnet#283 - Changing target framework causes incorrect binding redirects to be added to app.config 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 frameworkcommit1bc99dcAuthor: KevinRansom <kevinr@microsoft.com>Date: Mon Mar 16 14:55:02 2015 -0700Fixesdotnet#283 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 parenta2d770f commit709c760

File tree

6 files changed

+192
-170
lines changed

6 files changed

+192
-170
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type MultiTargeting() =
7373
use project= TheTests.CreateProject(projFile,"true", ccn, sp)
7474

7575
letvalidate(fn:System.Runtime.Versioning.FrameworkName)eR eS=
76-
let(name,runtime,sku)= project.DetermineRuntimeAndSKU(fn.ToString())
76+
let(runtime,sku)= project.DetermineRuntimeAndSKU(fn.ToString())
7777
Assert.AreEqual(eR, runtime)
7878
Assert.AreEqual(eS, sku)
7979
validate(new System.Runtime.Versioning.FrameworkName(".NETFramework",new System.Version(4,0)))"v4.0"".NETFramework,Version=v4.0"
@@ -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: 48 additions & 60 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,80 +3300,69 @@ 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
3305-
// update FSharp.Core only if we are addressing '.NETFramework' as opposed to e.g. Silverlight or Portable
3306-
if(frameworkName.Identifier==".NETFramework")
3307-
{
3308-
// In reality for FSharp.Core compatibility with .NetFramework selection looks like this:
3309-
// 2 is incompatible with 4
3310-
// 4.0 is incompatible with 4.5
3311-
// 4.5 is compatible with 4.5.1 and 4.5.2 and 4.6
3312-
varlower=oldFrameworkName.Version<frameworkName.Version?oldFrameworkName.Version:frameworkName.Version;
3313-
varupper=oldFrameworkName.Version<frameworkName.Version?frameworkName.Version:oldFrameworkName.Version;
3314-
varhasIncompatibleFsCore=(lower.Major!=upper.Major)||(lower.Major==4&&(lower.Minor<5&&upper.Minor>=5));
3308+
// In reality for FSharp.Core compatibility with .NetFramework selection looks like this:
3309+
// 2 is incompatible with 4
3310+
// 4.0 is incompatible with 4.5
3311+
// 4.5 is compatible with 4.5.1 and 4.5.2 and 4.6
3312+
varlower=oldFrameworkName.Version<frameworkName.Version?oldFrameworkName.Version:frameworkName.Version;
3313+
varupper=oldFrameworkName.Version<frameworkName.Version?frameworkName.Version:oldFrameworkName.Version;
3314+
varhasIncompatibleFsCore=(lower.Major!=upper.Major)||(lower.Major==4&&(lower.Minor<5&&upper.Minor>=5));
33153315

3316-
if(hasIncompatibleFsCore)
3317-
{
3318-
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-
;
3316+
if(hasIncompatibleFsCore)
3317+
{
3318+
varnewVersion=
3319+
frameworkName.Version.Major>=4?
3320+
(frameworkName.Version.Minor<5?newVersion(4,3,0,0):newVersion(4,4,0,0)):newVersion(2,3,0,0);
3321+
targetFSharpCoreVersion=newVersion.ToString();
33333322

3334-
if(projectMgr.CanUseTargetFSharpCoreReference)
3335-
{
3336-
// this project controls version of FSharp.Core with project level property TargetFSharpCoreVersion- set it
3337-
projectMgr.SetProjectProperty(ProjectFileConstants.TargetFSharpCoreVersion,newVersion.ToString());
3338-
}
3339-
else
3340-
{
3341-
// project doesn't use TargetFSharpCoreVersion - fix the reference explicitly
3342-
varfsCoreName=newSystem.Reflection.AssemblyName(string.Format("FSharp.Core, Culture=neutral, PublicKeyToken={0}",Utilities.FsCorePublicKeyToken));
3323+
if(projectMgr.CanUseTargetFSharpCoreReference)
3324+
{
3325+
// this project controls version of FSharp.Core with project level property TargetFSharpCoreVersion- set it
3326+
projectMgr.SetProjectProperty(ProjectFileConstants.TargetFSharpCoreVersion,targetFSharpCoreVersion);
3327+
}
3328+
else
3329+
{
3330+
// project doesn't use TargetFSharpCoreVersion - fix the reference explicitly
3331+
varfsCoreName=newSystem.Reflection.AssemblyName(string.Format("FSharp.Core, Culture=neutral, PublicKeyToken={0}",Utilities.FsCorePublicKeyToken));
33433332

3344-
varvsProj=(VSLangProj.VSProject)projectMgr.Object;
3333+
varvsProj=(VSLangProj.VSProject)projectMgr.Object;
33453334

3346-
varreferences=vsProj.References;
3335+
varreferences=vsProj.References;
33473336

3348-
// replace existing fscore with one that has matching version with current target framework
3349-
varexistingFsCore=
3350-
Microsoft.VisualStudio.FSharp.LanguageService.UIThread.DoOnUIThread(
3351-
()=>references
3352-
.OfType<Automation.OAAssemblyReference>()
3353-
.FirstOrDefault(r=>r.Name==fsCoreName.Name&&r.PublicKeyToken==Utilities.FsCorePublicKeyToken&&r.Culture==fsCoreName.CultureName)
3354-
);
3337+
// replace existing fscore with one that has matching version with current target framework
3338+
varexistingFsCore=
3339+
Microsoft.VisualStudio.FSharp.LanguageService.UIThread.DoOnUIThread(
3340+
()=>references
3341+
.OfType<Automation.OAAssemblyReference>()
3342+
.FirstOrDefault(r=>r.Name==fsCoreName.Name&&r.PublicKeyToken==Utilities.FsCorePublicKeyToken&&r.Culture==fsCoreName.CultureName)
3343+
);
33553344

3356-
if(existingFsCore!=null)
3345+
if(existingFsCore!=null)
3346+
{
3347+
Microsoft.VisualStudio.FSharp.LanguageService.UIThread.DoOnUIThread(()=>
33573348
{
3358-
Microsoft.VisualStudio.FSharp.LanguageService.UIThread.DoOnUIThread(()=>
3359-
{
3360-
// save copyLocal value - after calling existingFsCore.Remove() becomes invalid and can raise exceptions
3361-
varcopyLocal=existingFsCore.CopyLocal;
3362-
existingFsCore.Remove();
3363-
fsCoreName.Version=newVersion;
3364-
3365-
// stores assembly FQN
3366-
varnewRef=references.Add(fsCoreName.FullName);
3367-
newRef.CopyLocal=copyLocal;
3368-
});
3369-
}
3349+
// save copyLocal value - after calling existingFsCore.Remove() becomes invalid and can raise exceptions
3350+
varcopyLocal=existingFsCore.CopyLocal;
3351+
existingFsCore.Remove();
3352+
fsCoreName.Version=newVersion;
3353+
3354+
// stores assembly FQN
3355+
varnewRef=references.Add(fsCoreName.FullName);
3356+
newRef.CopyLocal=copyLocal;
3357+
});
33703358
}
33713359
}
33723360
}
33733361
#endif
33743362

33753363
try
33763364
{
3377-
this.projectMgr.FixupAppConfigOnTargetFXChange(newTargetFrameworkMoniker);
3365+
this.projectMgr.FixupAppConfigOnTargetFXChange(newTargetFrameworkMoniker,targetFSharpCoreVersion,autoGenerateBindingRedirects);
33783366
}
33793367
catch(Exceptione)
33803368
{

‎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.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp