Post build script returning errorlevel 255
Asked Answered
G

2

6

I currently have the following script as post build on a project:

if $(ConfigurationName) == "Debug (x64)" || $(ConfigurationName) == "Release (x64)" (goto :x64)
if $(ConfigurationName) == "Debug" || $(ConfigurationName) == "Release" (goto :x86)

:x64
copy "$(SolutionDir)References\x64\System.Data.SQLite.dll" "$(TargetDir)System.Data.SQLite.dll"
goto :default

:x86
copy "$(SolutionDir)References\System.Data.SQLite.dll" "$(TargetDir)System.Data.SQLite.dll"
goto :default

:default
copy "$(SolutionDir)References\System.Data.SQLite.Linq.dll" "$(TargetDir)System.Data.SQLite.Linq.dll"

(it copies the x86 or x64 version of the assembly to the output folder according to the Configuration)

This script returns error level 255, and as I have no idea of batch scripting, could somebody point me to the error?

Gravedigger answered 12/10, 2010 at 22:23 Comment(0)
V
5

As far as I know, the IF in batch files does not support C like syntax of ORing together multiple expressions.

So as a first try, change these first lines of your script from:

if $(ConfigurationName) == "Debug (x64)" || $(ConfigurationName) == "Release (x64)" (goto :x64)
if $(ConfigurationName) == "Debug" || $(ConfigurationName) == "Release" (goto :x86)

to:

if "$(ConfigurationName)"=="Debug (x64)" goto :x64
if "$(ConfigurationName)"=="Release (x64)" goto :x64
if "$(ConfigurationName)"=="Debug" goto :x86
if "$(ConfigurationName)"=="Release" goto :x86

Also note the added " around the $(ConfigurationName).
The rest should work fine.

Vania answered 12/10, 2010 at 22:43 Comment(0)
C
10

In cmd.exe, type net helpmsg 255:

The extended attributes are inconsistent.

I have no idea if that's the actual error, but it's a handy way to decipher Win32 error codes.

Carangid answered 12/10, 2010 at 22:28 Comment(1)
Extremely handy! What a wonderful tip; you learn something new everyday while surfing stack overflow.Urinate
V
5

As far as I know, the IF in batch files does not support C like syntax of ORing together multiple expressions.

So as a first try, change these first lines of your script from:

if $(ConfigurationName) == "Debug (x64)" || $(ConfigurationName) == "Release (x64)" (goto :x64)
if $(ConfigurationName) == "Debug" || $(ConfigurationName) == "Release" (goto :x86)

to:

if "$(ConfigurationName)"=="Debug (x64)" goto :x64
if "$(ConfigurationName)"=="Release (x64)" goto :x64
if "$(ConfigurationName)"=="Debug" goto :x86
if "$(ConfigurationName)"=="Release" goto :x86

Also note the added " around the $(ConfigurationName).
The rest should work fine.

Vania answered 12/10, 2010 at 22:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.