Unable to run C# scripts: CS1024: Preprocessor directive expected


(lance.h) #1

After upgrade from 4.x to 2018.8.6 our C# scripts (in our deployment steps, e.g. for pre-deployment of Azure App Service deployment) are no longer working and blocking most of our deployments.

The error for all is basically the same:

ERROR: Script compilation failed. [CompilationErrorException] C:\Octopus\Work\20181217232007-49732-14\staging\Octopus.AzureContext.ps1(1,1): error CS1024: Preprocessor directive expected 
December 18th 2018 12:20:20Error
PreDeploy script returned non-zero exit code: 1 
December 18th 2018 12:20:20Error
Running rollback conventions... 
December 18th 2018 12:20:20Error
PreDeploy script returned non-zero exit code: 1 

One of our simpler scripts is as follows:

if(Octopus.Parameters["DoProductionRobots"] == "True") {
   Console.WriteLine("Replacing robots.txt with Production version");
   File.Delete("wwwroot\\robots.txt");
   File.Move("wwwroot\\robots.production.txt", "wwwroot\\robots.txt");
}

Googling this error doesn’t bring up anything useful.

This was working in our previous version of Octopus (4.0.9)


(lance.h) #2

Update

The script mentioned in the original comment is running as the “Pre-deployment script” of “Custom Deployment Scripts” of the “Deploy an Azure Web App” step.

Strangely, I can successfully run a step template based using C# directly through Library - Step Templates (I mention this because we’ve had issues with ScriptCS breaking almost every time we’ve upgrade Octopus Deploy and it turns out those instances that the ScriptCS folder was missing on the server)


(Shane Gill) #3

Hi,

Thanks for getting in touch.

I can reproduce the issue, it is a bug in the code that is attempting to run the C# scripts. I’ve created a priority issue to resolve here: https://github.com/OctopusDeploy/Issues/issues/5178

Cheers,
Shane


(system) #4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.