Search code examples
c#octopus-deploy

Folder/Directory Creation on Deployment Targets


I am deploying a small script to the target PC using Octopus Deploy but the script is not generating a new folder on the target machine. Is there a problem in my code or is it a problem with the deployment setup?

using System;
using System.IO;

class FolderCreation
{
    public static void Main()
    {
        string _basePath = @"c:\OD_Test";
        try
        {
            string dateFolder = DateTime.Now.ToString("yyyy-MM-dd");
            string path = $"{_basePath}\\{dateFolder}";

            System.IO.Directory.CreateDirectory(path);
        }
        catch (Exception ex)
        {
             Console.WriteLine("The process failed: {0}", ex.ToString());
        }
    }
}

Solution

  • Octopus Deploy only allows script files to be accepted. I was NOT supposed to create a class itself but only include the information inside the main method. Functions can be added by using OD's script modules.