-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameterize product version #8031
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
||
namespace FSharp.Build | ||
|
||
open System | ||
open System.Collections | ||
open System.IO | ||
open Microsoft.Build.Framework | ||
open Microsoft.Build.Utilities | ||
|
||
type SubstituteText () = | ||
|
||
let mutable _buildEngine : IBuildEngine = null | ||
let mutable _hostObject : ITaskHost = null | ||
|
||
let mutable copiedFiles = new ResizeArray<ITaskItem>() | ||
let mutable embeddedResources : ITaskItem[] = [||] | ||
|
||
[<Required>] | ||
member this.EmbeddedResources | ||
with get() = embeddedResources | ||
and set(value) = embeddedResources <- value | ||
|
||
[<Output>] | ||
member this.CopiedFiles | ||
with get() = copiedFiles.ToArray() | ||
|
||
interface ITask with | ||
member this.BuildEngine | ||
with get() = _buildEngine | ||
and set(value) = _buildEngine <- value | ||
|
||
member this.HostObject | ||
with get() = _hostObject | ||
and set(value) = _hostObject <- value | ||
|
||
member this.Execute() = | ||
copiedFiles.Clear() | ||
if not(isNull embeddedResources) then | ||
for item in embeddedResources do | ||
// Update ITaskItem metadata to point to new location | ||
let sourcePath = item.GetMetadata("FullPath") | ||
|
||
let pattern1 = item.GetMetadata("Pattern1") | ||
let pattern2 = item.GetMetadata("Pattern2") | ||
|
||
// Is there any replacement to do? | ||
if not (String.IsNullOrWhiteSpace(pattern1) && String.IsNullOrWhiteSpace(pattern2)) then | ||
if not(String.IsNullOrWhiteSpace(sourcePath)) then | ||
try | ||
let getTargetPathFrom key = | ||
let md = item.GetMetadata(key) | ||
let path = Path.GetDirectoryName(md) | ||
let filename = Path.GetFileName(md) | ||
let target = Path.Combine(path, @"..\resources", filename) | ||
target | ||
|
||
// Copy from the location specified in Identity | ||
let sourcePath=item.GetMetadata("Identity") | ||
|
||
// Copy to the location specified in TargetPath unless no TargetPath is provided, then use Identity | ||
let targetPath= | ||
let identityPath = getTargetPathFrom "Identity" | ||
let intermediateTargetPath = item.GetMetadata("IntermediateTargetPath") | ||
if not (String.IsNullOrWhiteSpace(intermediateTargetPath)) then | ||
let filename = Path.GetFileName(identityPath) | ||
let target = Path.Combine(intermediateTargetPath, filename) | ||
target | ||
else | ||
identityPath | ||
|
||
item.ItemSpec <- targetPath | ||
|
||
// Transform file | ||
let mutable contents = File.ReadAllText(sourcePath) | ||
if not (String.IsNullOrWhiteSpace(pattern1)) then | ||
let replacement = item.GetMetadata("Replacement1") | ||
contents <- contents.Replace(pattern1, replacement) | ||
if not (String.IsNullOrWhiteSpace(pattern2)) then | ||
let replacement = item.GetMetadata("Replacement2") | ||
contents <- contents.Replace(pattern2, replacement) | ||
|
||
let directory = Path.GetDirectoryName(targetPath) | ||
if not(Directory.Exists(directory)) then | ||
Directory.CreateDirectory(directory) |>ignore | ||
|
||
File.WriteAllText(targetPath, contents) | ||
with | ||
| _ -> () | ||
|
||
copiedFiles.Add(item) | ||
true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -464,10 +464,10 @@ | |
<value>Customizes the environment to maximize code editor screen space and improve the visibility of F# commands and tool windows.</value> | ||
</data> | ||
<data name="ProductDetails" xml:space="preserve"> | ||
<value>Microsoft Visual F# Tools 10.4 for F# 4.6</value> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like the hackery in the project file. I'd rather There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel you … unfortunately these values are read by vs from the resource strings. We just tell VS the resource IDs it then grabs the resources and displays them. Here. We can put the build targets in FSharpBuild.Directory.Build.targets in order to remove the hackery from the project. The bit I'm still trying to figure out, is how to not break xlf, and yet update the localized versions of vspackage ... all in all it is quite touchy. |
||
<value>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</value> | ||
</data> | ||
<data name="9002" xml:space="preserve"> | ||
<value>Microsoft Visual F# Tools 10.4 for F# 4.6</value> | ||
<value>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</value> | ||
</data> | ||
<data name="ProductID" xml:space="preserve"> | ||
<value>1.0</value> | ||
|
@@ -476,7 +476,7 @@ | |
<value>Microsoft Visual F# Tools</value> | ||
</data> | ||
<data name="9001" xml:space="preserve"> | ||
<value>Visual F# Tools 10.4 for F# 4.6</value> | ||
<value>Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</value> | ||
</data> | ||
<data name="9027" xml:space="preserve"> | ||
<value>F# Interactive</value> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably won't work unless we specially handle
@(ContentSubstituteText)
, otherwise the VSSDK probably won't find the.pkgdef
in the@(None)
collection.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brettfo I believe the VSSDK picks the packagedefs out of the output directory and since the NoneSubstituteText puts the transformed file there, all is good..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brettfo, Okay fixed it.