-
Notifications
You must be signed in to change notification settings - Fork 588
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
Add support for Kudu Zip Deploy #1757
Changes from all commits
77700f4
01c4bb7
e001a5b
68d284f
1efbe01
a83ca62
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,17 @@ | ||
// Auto-Generated by FAKE; do not edit | ||
namespace System | ||
open System.Reflection | ||
|
||
[<assembly: AssemblyTitleAttribute("FAKE - F# Make Azure Cloud Services Support")>] | ||
[<assembly: AssemblyProductAttribute("FAKE - F# Make")>] | ||
[<assembly: AssemblyVersionAttribute("5.0.0")>] | ||
[<assembly: AssemblyInformationalVersionAttribute("5.0.0")>] | ||
[<assembly: AssemblyFileVersionAttribute("5.0.0")>] | ||
do () | ||
|
||
module internal AssemblyVersionInformation = | ||
let [<Literal>] AssemblyTitle = "FAKE - F# Make Azure Cloud Services Support" | ||
let [<Literal>] AssemblyProduct = "FAKE - F# Make" | ||
let [<Literal>] AssemblyVersion = "5.0.0" | ||
let [<Literal>] AssemblyInformationalVersion = "5.0.0" | ||
let [<Literal>] AssemblyFileVersion = "5.0.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/// Contains tasks to package Azure Cloud Services. | ||
module Fake.Azure.CloudServices | ||
|
||
open System.IO | ||
open Fake.Core | ||
open Fake.IO | ||
open Fake.IO.Globbing.Operators | ||
|
||
/// Configuration details for packaging cloud services. | ||
[<CLIMutable>] | ||
type PackageCloudServiceParams = | ||
{ /// The name of the Cloud Service. | ||
CloudService : string | ||
/// The name of the role in the service. | ||
WorkerRole : string | ||
/// The SDK version to use e.g. 2.2. If None, the latest available version is used. | ||
SdkVersion : float option | ||
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. Version is a float? 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 copied all this from the |
||
/// The output path for the .cspkg. | ||
OutputPath : string option } | ||
|
||
let DefaultCloudServiceParams = { CloudService = ""; WorkerRole = ""; SdkVersion = None; OutputPath = None } | ||
|
||
module VmSizes = | ||
type VmSize = | VmSize of size:string | ||
let ExtraSmall = VmSize "ExtraSmall" | ||
let Small = VmSize "Small" | ||
let Medium = VmSize "Medium" | ||
let Large = VmSize "Large" | ||
let ExtraLarge = VmSize "ExtraLarge" | ||
let A5 = VmSize "A5" | ||
let A6 = VmSize "A6" | ||
let A7 = VmSize "A7" | ||
let A8 = VmSize "A8" | ||
let A9 = VmSize "A9" | ||
|
||
/// Modifies the size of the Worker Role in the csdef. | ||
let ModifyVMSize (VmSizes.VmSize vmSize) cloudService = | ||
let csdefPath = sprintf @"%s\ServiceDefinition.csdef" cloudService | ||
csdefPath | ||
|> File.ReadAllText | ||
|> Xml.Doc | ||
|> Xml.XPathReplaceNS | ||
"/svchost:ServiceDefinition/svchost:WorkerRole/@vmsize" | ||
vmSize | ||
[ "svchost", "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" ] | ||
|> fun doc -> | ||
use fileStream = new FileStream(csdefPath, FileMode.Create) | ||
doc.Save fileStream | ||
|
||
/// Packages a cloud service role into a .cspkg, ready for deployment. | ||
let PackageRole packageCloudServiceParams = | ||
let csPack = | ||
let sdkRoots = | ||
[ @"C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\" | ||
@"C:\Program Files\Microsoft SDKs\Azure\.NET SDK\" ] | ||
|
||
let availableCsPacks = | ||
sdkRoots | ||
|> Seq.collect(fun sdkRoot -> | ||
!! (sdkRoot + @"**\cspack.exe") | ||
|> Seq.filter(fun path -> path.Substring(sdkRoot.Length).StartsWith "v") | ||
|> Seq.map(fun path -> sdkRoot, path)) | ||
|> Seq.map(fun (sdkRoot, cspackPath) -> | ||
let version = | ||
cspackPath.Substring(sdkRoot.Length).Split '\\' | ||
|> Seq.head | ||
|> fun version -> version.Substring 1 | ||
|> float | ||
version, sdkRoot, cspackPath) | ||
|> Seq.cache | ||
|
||
match packageCloudServiceParams.SdkVersion with | ||
| Some version -> | ||
availableCsPacks | ||
|> Seq.tryFind(fun (csPackVersion,_,_) -> csPackVersion = version) | ||
|> Option.map(fun (_,_,csPackFileInfo) -> csPackFileInfo) | ||
| None -> | ||
availableCsPacks | ||
|> Seq.sortBy(fun (v,_,_) -> -v) | ||
|> Seq.map(fun (_,_,csPackFileInfo) -> csPackFileInfo) | ||
|> Seq.tryFind(fun _ -> true) | ||
|
||
csPack | ||
|> Option.map(fun csPack -> | ||
packageCloudServiceParams.OutputPath |> Option.iter(DirectoryInfo.ensure << DirectoryInfo.ofPath) | ||
let outputFileArg = | ||
packageCloudServiceParams.OutputPath | ||
|> Option.map(fun path -> Path.Combine(path, (packageCloudServiceParams.CloudService + ".cspkg"))) | ||
|> Option.map(sprintf "/out:%s") | ||
|> defaultArg | ||
<| "" | ||
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. This is a bit unusual 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 copied all this from the |
||
|
||
Process.shellExec | ||
{ ExecParams.Empty with | ||
Program = csPack | ||
CommandLine = sprintf @"%s\ServiceDefinition.csdef /role:%s;%s\bin\release;%s.dll %s" packageCloudServiceParams.CloudService packageCloudServiceParams.WorkerRole packageCloudServiceParams.WorkerRole packageCloudServiceParams.WorkerRole outputFileArg | ||
Args = [] }) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net46;netstandard1.6;netstandard2.0</TargetFrameworks> | ||
<AssemblyName>Fake.Azure.CloudServices</AssemblyName> | ||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="AssemblyInfo.fs" /> | ||
<Compile Include="CloudServices.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Fake.Core.Context\Fake.Core.Context.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.Environment\Fake.Core.Environment.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.Process\Fake.Core.Process.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.String\Fake.Core.String.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.Xml\Fake.Core.Xml.fsproj" /> | ||
<ProjectReference Include="..\Fake.IO.FileSystem\Fake.IO.FileSystem.fsproj" /> | ||
</ItemGroup> | ||
<Import Project="..\..\..\.paket\Paket.Restore.targets" /> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
group netcore | ||
|
||
FSharp.Core | ||
NETStandard.Library | ||
System.Diagnostics.FileVersionInfo | ||
System.Diagnostics.Process | ||
System.IO.FileSystem.Watcher | ||
System.Xml.XDocument | ||
System.Xml.XPath | ||
System.Xml.XPath.XDocument | ||
System.Xml.XPath.XmlDocument | ||
System.Xml.ReaderWriter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Auto-Generated by FAKE; do not edit | ||
namespace System | ||
open System.Reflection | ||
|
||
[<assembly: AssemblyTitleAttribute("FAKE - F# Make Azure Emulators Support")>] | ||
[<assembly: AssemblyProductAttribute("FAKE - F# Make")>] | ||
[<assembly: AssemblyVersionAttribute("5.0.0")>] | ||
[<assembly: AssemblyInformationalVersionAttribute("5.0.0")>] | ||
[<assembly: AssemblyFileVersionAttribute("5.0.0")>] | ||
do () | ||
|
||
module internal AssemblyVersionInformation = | ||
let [<Literal>] AssemblyTitle = "FAKE - F# Make Azure Emulators Support" | ||
let [<Literal>] AssemblyProduct = "FAKE - F# Make" | ||
let [<Literal>] AssemblyVersion = "5.0.0" | ||
let [<Literal>] AssemblyInformationalVersion = "5.0.0" | ||
let [<Literal>] AssemblyFileVersion = "5.0.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/// Contains tasks to control the local Azure Emulator | ||
module Fake.Azure.Emulators | ||
|
||
open System | ||
open Fake.Core | ||
open Fake.IO | ||
open Fake.IO.FileSystemOperators | ||
|
||
/// A type for the controlling parameter | ||
[<CLIMutable>] | ||
type private AzureEmulatorParams = { | ||
StorageEmulatorToolPath:Lazy<string> | ||
CSRunToolPath:string | ||
TimeOut:TimeSpan | ||
} | ||
|
||
/// Base path for getting tools from Microsoft SDKs | ||
let msSdkBasePath = Environment.ProgramFilesX86 @@ "Microsoft SDKs" | ||
|
||
/// The default parameters for Azure emulators | ||
let private AzureEmulatorDefaults = { | ||
StorageEmulatorToolPath = | ||
lazy | ||
let path = msSdkBasePath @@ @"\Azure\Storage Emulator\AzureStorageEmulator.exe" | ||
if File.exists path then path | ||
else failwith (sprintf "Unable to locate Azure Storage Emulator at %s" path) | ||
CSRunToolPath = "\"C:\Program Files\Microsoft SDKs\Windows Azure\Emulator\csrun.exe\"" | ||
TimeOut = TimeSpan.FromMinutes 5. | ||
} | ||
|
||
let private (|StorageAlreadyStarted|StorageAlreadyStopped|Ok|OtherError|) = function | ||
| 0 -> Ok | ||
| -5 -> StorageAlreadyStarted | ||
| -6 -> StorageAlreadyStopped | ||
| _ -> OtherError | ||
|
||
/// Stops the storage emulator | ||
let StopStorageEmulator = (fun _ -> | ||
match Process.Exec (fun info -> | ||
{ info with | ||
FileName = AzureEmulatorDefaults.StorageEmulatorToolPath.Value | ||
Arguments = "stop" }) AzureEmulatorDefaults.TimeOut with | ||
| Ok | StorageAlreadyStopped -> () | ||
| _ -> failwithf "Azure Emulator Failure on stop Storage Emulator" | ||
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. Maybe we need some more information here, if you want to hide it you can use inner exceptions, like But that is only a suggestion if you left that information out on purpose, otherwise we might just include the exit code in the error message... 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 copied all this from the |
||
) | ||
|
||
/// Starts the storage emulator | ||
let StartStorageEmulator = (fun _ -> | ||
match Process.Exec (fun info -> | ||
{ info with | ||
FileName = AzureEmulatorDefaults.StorageEmulatorToolPath.Value | ||
Arguments = "start" }) AzureEmulatorDefaults.TimeOut with | ||
| Ok | StorageAlreadyStarted -> () | ||
| _ -> failwithf "Azure Emulator Failure on start Storage Emulator" | ||
) | ||
|
||
/// Stops the compute emulator | ||
let StopComputeEmulator = (fun _ -> | ||
if 0 <> Process.Exec (fun info -> | ||
{ info with | ||
FileName = AzureEmulatorDefaults.CSRunToolPath | ||
Arguments = "/devfabric:shutdown" }) AzureEmulatorDefaults.TimeOut | ||
then | ||
failwithf "Azure Emulator Failure on stop Fabric Emulator" | ||
) | ||
|
||
/// Starts the compute emulator | ||
let StartComputeEmulator = (fun _ -> | ||
if 0 <> Process.Exec (fun info -> | ||
{ info with | ||
FileName = AzureEmulatorDefaults.CSRunToolPath | ||
Arguments = "/devfabric:start" }) AzureEmulatorDefaults.TimeOut | ||
then | ||
failwithf "Azure Emulator Failure on start Fabric Emulator" | ||
) | ||
|
||
/// Resets the devstore (BLOB, Queues and Tables) | ||
let ResetDevStorage = (fun _ -> | ||
if 0 <> Process.Exec (fun info -> | ||
{ info with | ||
FileName = AzureEmulatorDefaults.StorageEmulatorToolPath.Value | ||
Arguments = "clear all" }) AzureEmulatorDefaults.TimeOut | ||
then | ||
failwithf "Azure Emulator Failure on reset Dev Storage" | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net46;netstandard1.6;netstandard2.0</TargetFrameworks> | ||
<AssemblyName>Fake.Azure.Emulators</AssemblyName> | ||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="AssemblyInfo.fs" /> | ||
<Compile Include="Emulators.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Fake.Core.Context\Fake.Core.Context.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.Environment\Fake.Core.Environment.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.Process\Fake.Core.Process.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.String\Fake.Core.String.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.Trace\Fake.Core.Trace.fsproj" /> | ||
<ProjectReference Include="..\Fake.IO.FileSystem\Fake.IO.FileSystem.fsproj" /> | ||
</ItemGroup> | ||
<Import Project="..\..\..\.paket\Paket.Restore.targets" /> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
group netcore | ||
|
||
FSharp.Core | ||
NETStandard.Library | ||
System.Diagnostics.FileVersionInfo | ||
System.Diagnostics.Process | ||
System.IO.FileSystem.Watcher |
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.
Can we remove
CLIMutable
here?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.
I copied all this from the
FakeLib
project in an attempt to be helpful to get this moved to Fake 5.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.
Yes I know and this helps a lot! I just like APIs to be more consistent in fake5 so we can improve the code while porting - this moves the project forward. I see that people want to use stuff on fake5. That’s why I said the items are suggestions just in case you agree with them and have a minute ;)