예제 #1
0
        public void MixIn(string directory)
        {
            if (!Arguments.Azure)
            {
                return;
            }
            // Move everything under the _source folder
            var sourceFolder = Path.Combine(directory, "_source");

            if (!fileSystem.Directory.Exists(sourceFolder))
            {
                fileSystem.Directory.CreateDirectory(sourceFolder);
            }

            foreach (var file in fileSystem.Directory.GetFiles(directory))
            {
                var trimStart = file.Replace(directory, string.Empty).TrimStart(Path.DirectorySeparatorChar);
                fileSystem.File.Move(file, Path.Combine(sourceFolder, trimStart));
            }

            foreach (var directoryToMove in fileSystem.Directory.GetDirectories(directory).Where(n => new DirectoryInfo(n).Name != "_source"))
            {
                var trimStart = directoryToMove.Replace(directory, string.Empty).TrimStart(Path.DirectorySeparatorChar);
                fileSystem.Directory.Move(directoryToMove, Path.Combine(sourceFolder, trimStart));
            }

            fileSystem.File.WriteAllText(Path.Combine(directory, @"Shim.cs"), Properties.RazorAzure.Shim);
            fileSystem.File.WriteAllText(Path.Combine(directory, @"Shim.csproj"), Properties.RazorAzure.ShimProject);
            fileSystem.File.WriteAllText(Path.Combine(directory, @"Shim.sln"), Properties.RazorAzure.ShimSolution);

            var currentPath = assembly.GetEntryAssemblyLocation();
            var destination = Path.Combine(directory, "Pretzel.exe");

            if (!fileSystem.File.Exists(destination))
            {
                fileSystem.File.Copy(currentPath, destination);
            }

            Tracing.Info("Shim project added to allow deployment to azure websites");
        }