cs-script: Error "Cannot parse "//css_import..."" when referencing an assembly

When having this line somewhere at the top of my script file:

//css_ref C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.dll

I get an error message:

Cannot parse “//css_import…”

Full stack trace:

System.ApplicationException: Cannot parse "//css_import..."
   at csscript.CSharpParser.ImportInfo.InternalInit(String[] statementParts, Int32 startIndex)
   at csscript.CSharpParser.ImportInfo.ResolveStatement(String statement, String parentScript, String[] probinghDirs)
   at csscript.CSharpParser.Init(String code, String file, String[] directivesToSearch, String[] probingDirs)
   at csscript.CSharpParser.Construct(String script, Boolean isFile, String[] directivesToSearch, String[] probingDirs)
   at csscript.CSExecutor.Execute(String[] args, PrintDelegate printDelg, String primaryScript)

I’ve tried to escale the “(” and “)” like this:

//css_ref C:\Program Files ((x86))\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.dll

And also tried to enclose the path within single quotes or double quotes.

Still, I’m unable to get rid of the above error.

My question

How can I css_ref an assembly that is located inside a path with both spaces and round brackets?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Got it, Thank you!

Guys, please test the v3.30.2 release: https://github.com/oleg-shilo/cs-script/releases/edit/v3.30.2.1

Install-Package CS-Script -Version 3.30.2-HotFix

It should fix the problem.

Hi Uwe. I cannot reproduce it. Seems to work for me:

image

in v3.28.9 image

Try to use envars: //css_ref %PROGRAMFILES(X86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.dll