提交 2298fdba 编写于 作者: B Brett V. Forsgren

allow `FSharpTargetsPath` to be properly overwritten in a project file

上级 704c1e30
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.FSharp.NetSdk.props" />
<Import Condition="'$(FSharpCompilerPath)' != ''" Project="$(FSharpCompilerPath)\Microsoft.FSharp.NetSdk.props" />
<Import Condition="'$(FSharpCompilerPath)' == ''" Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.FSharp.NetSdk.props" />
</Project>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.FSharp.NetSdk.targets" />
<Import Condition="'$(FSharpCompilerPath)' != ''" Project="$(FSharpCompilerPath)\Microsoft.FSharp.NetSdk.targets" />
<Import Condition="'$(FSharpCompilerPath)' == ''" Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.FSharp.NetSdk.targets" />
</Project>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.FSharp.Overrides.NetSdk.targets" />
<Import Condition="'$(FSharpCompilerPath)' != ''" Project="$(FSharpCompilerPath)\Microsoft.FSharp.Overrides.NetSdk.targets" />
<Import Condition="'$(FSharpCompilerPath)' == ''" Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.FSharp.Overrides.NetSdk.targets" />
</Project>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.FSharp.targets" />
<Import Condition="'$(FSharpCompilerPath)' != ''" Project="$(FSharpCompilerPath)\Microsoft.FSharp.targets" />
<Import Condition="'$(FSharpCompilerPath)' == ''" Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.FSharp.targets" />
</Project>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.Portable.FSharp.targets" />
<Import Condition="'$(FSharpCompilerPath)' != ''" Project="$(FSharpCompilerPath)\Microsoft.Portable.FSharp.targets" />
<Import Condition="'$(FSharpCompilerPath)' == ''" Project="$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharp\Microsoft.Portable.FSharp.targets" />
</Project>
......@@ -22,10 +22,5 @@ type internal SetGlobalPropertiesForSdkProjects
inherit StaticGlobalPropertiesProviderBase(projectService.Services)
override __.GetGlobalPropertiesAsync(_cancellationToken: CancellationToken): Task<IImmutableDictionary<string, string>> =
let editorDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
[ "FSharpPropsShim", "Microsoft.FSharp.NetSdk.props"
"FSharpTargetsShim", "Microsoft.FSharp.NetSdk.targets"
"FSharpOverridesTargetsShim", "Microsoft.FSharp.Overrides.NetSdk.targets" ]
|> List.map (fun (key, value) -> (key, Path.Combine(editorDirectory, value)))
|> List.fold (fun (map:ImmutableDictionary<string, string>) (key, value) -> map.Add(key, value)) (Empty.PropertiesMap)
|> Task.FromResult<IImmutableDictionary<string, string>>
let properties = Empty.PropertiesMap.Add("FSharpCompilerPath", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
Task.FromResult<IImmutableDictionary<string, string>>(properties)
......@@ -738,12 +738,14 @@ public static Microsoft.Build.Evaluation.Project InitializeMsBuildProject(Micros
if (buildProject == null)
{
buildProject = buildEngine.LoadProject(fullProjectPath);
var globalProperties = new Dictionary<string, string>()
{
{ "FSharpCompilerPath", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) }
};
buildProject = buildEngine.LoadProject(fullProjectPath, globalProperties, null);
buildProject.IsBuildEnabled = true;
}
buildProject.SetProperty("FSharpTargetsPath", Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Microsoft.FSharp.targets"));
return buildProject;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册