Skip to content
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

Added modules for building VB6 projects with SxS manifests #697

Merged
merged 5 commits into from
Mar 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/app/FakeLib/EnvironmentHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ let mutable TargetPlatformPrefix =
else Some @"C:\Windows\Microsoft.NET\Framework"
|> Option.get

/// Base path for getting tools from windows SDKs
let sdkBasePath = ProgramFilesX86 @@ "Microsoft SDKs\Windows"

/// Helper function to help find framework or sdk tools from the
/// newest toolkit available
let getNewestTool possibleToolPaths =
possibleToolPaths
|> Seq.sortBy (fun p -> p)
|> Array.ofSeq
|> Array.rev
|> Seq.ofArray
|> Seq.head

/// Gets the local directory for the given target platform
let getTargetPlatformDir platformVersion =
if Directory.Exists(TargetPlatformPrefix + "64") then (TargetPlatformPrefix + "64") @@ platformVersion
Expand Down
2 changes: 2 additions & 0 deletions src/app/FakeLib/FakeLib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@
<Compile Include="AzureWebJobs.fs" />
<Compile Include="HockeyAppHelper.fs" />
<Compile Include="AzureCloudServices.fs" />
<Compile Include="Sxshelper.fs" />
<Compile Include="Vb6helper.fs" />
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
Expand Down
55 changes: 54 additions & 1 deletion src/app/FakeLib/RegAsmHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
module Fake.RegAsmHelper

open System
open System.IO

/// Path to newest `regasm.exe`
let regAsmToolPath = !! (TargetPlatformPrefix + "/**/RegAsm.exe")
|> getNewestTool

/// RegAsm parameter type
type RegAsmParams =
Expand All @@ -13,7 +18,7 @@ type RegAsmParams =

/// RegAsm default params
let RegAsmDefaults =
{ ToolPath = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe"
{ ToolPath = regAsmToolPath
WorkingDir = "."
TimeOut = TimeSpan.FromMinutes 5.
ExportTypeLibrary = true }
Expand All @@ -36,3 +41,51 @@ let RegAsm setParams lib =
info.Arguments <- args) parameters.TimeOut
then failwithf "RegAsm %s failed." args
traceEndTask "RegAsm" lib

/// Executes `RegAsm.exe` with the `/codebase` `/tlb` option
///
/// Used to temporarily register any .net dependencies before running
/// a VB6 build
let public RegisterAssembliesWithCodebase workingDir (assemblies:string seq) =
traceStartTask "Regasm with codebase" "Registering assemblies with codebase, expect warnings"
let registerAssemblyWithCodebase assembly =
async {
let! regAsmResult =
asyncShellExec {defaultParams with
Program = regAsmToolPath
WorkingDirectory = workingDir
CommandLine = (sprintf "\"%s\" /tlb:%s /codebase" assembly ((Path.GetFileName assembly) + ".tlb"))
}
if regAsmResult <> 0 then failwith (sprintf "Register %s with codebase failed" assembly)
return ()
}
assemblies
|> Seq.map registerAssemblyWithCodebase
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
traceEndTask "Regasm with codebase" "Registering assemblies with codebase, expect warnings"

/// Executes `Regasm.exe` with the `/codebase /tlb /unregister` options
///
/// Used to unregegister any temporarily registerd .net dependencies
/// _after_ running a VB6 build
let public UnregisterAssemblies workingDir (assemblies:string seq) =
traceStartTask "Regasm /unregister with codebase" "Registering assemblies with codebase, expect warnings"
let registerAssemblyWithCodebase assembly =
async {
let! regAsmResult =
asyncShellExec {defaultParams with
Program = regAsmToolPath
WorkingDirectory = workingDir
CommandLine = (sprintf "\"%s\" /tlb:%s /codebase /unregister" assembly ((Path.GetFileName assembly) + ".tlb"))
}
if regAsmResult <> 0 then failwith (sprintf "Unregister %s with codebase failed" assembly)
return ()
}
assemblies
|> Seq.map registerAssemblyWithCodebase
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
traceEndTask "Regasm /unregister with codebase" "Registering assemblies with codebase, expect warnings"
Loading