Skip to content

Commit

Permalink
Merge pull request #697 from Vidarls/vb6
Browse files Browse the repository at this point in the history
Added modules for building VB6 projects with SxS manifests
  • Loading branch information
forki committed Mar 22, 2015
2 parents d578d1c + 40b9b2f commit 3189782
Show file tree
Hide file tree
Showing 5 changed files with 721 additions and 1 deletion.
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

0 comments on commit 3189782

Please sign in to comment.