Search code examples
tfsbuildstring-interpolation

tfs build server - string interpolation $ Character is not valid


i am using string interpolation using $ in my code. It compiles fine but when i check in my code, the build server throws an error BC30037: Character is not valid. Following is an example on how i have used string interpolation:

dim r = New RadNode($"{acq.FormNo} -  ${CInt(acq.TotalAmount)}", icon:=RadTreeIcons.RedTriangle)

The build server has Visual Studio 2015 Entreprise edition installed.

If i run this from command prompt:

C:\Program Files (x86)\MSBuild\14.0\Bin>MSBuild /tv:14.0 "Proj.sln", the code compiles file. However if i change the above argument to

C:\Program Files (x86)\MSBuild\14.0\Bin>MSBuild /tv:12.0 "Proj.sln", i get the same error

I have also made these changes:

i have set the MSBuildArguments Property to /p:VisualStudioVersion=14.0 and also changed the TFSBuild.proj file and changed this line to <Project DefaultTargets="DesktopBuild" xmlns="schemas.microsoft.com/developer/msbuild/2003"; ToolsVersion="14.0">" but same issue is happening.

Changed the (web vbproj) file and changed ToolSet Version to 14.0 from 12.0. Other vb projects part of the solution are still targeting 12.0 but gets compiled in dll as part of web vb project.


Solution

  • Answer located here solved my problem:

    BuildActivity ignores ToolsVersion

    For those of us not living inside build templates every day here's the steps that got it working for me:

    First find the template associated with your build (if you already know where to find it skip a couple steps).

    Just right click the build definition and select Edit build definition Select the Process tab and you'll see the name of the template (quite likely to be DefaultTemplate if you haven't customized it). On the far right click Show details to see the path for the template.

    enter image description here

    Go to the Home tab under Team explorer and click Source control explorer enter image description here

    Find the template file and double click to edit it. It should come up in a graphical view like this. Scroll till you find Run MSBuild for Project enter image description here

    Click on this item which will immediately bring up properties enter image description here

    Click on the little icon on the right - don't try and type it in because it'll probably explode and crash Visual Studio. Enter IN QUOTES the following "C:\Program Files (x86)\MSBuild\14.0\bin" enter image description here

    NOW FOR THE MOST IMPORTANT PART

    For me the Run MSBuild for Project was in TWO places.

    So I just repeated the above steps in both places, and then after I checked in the .xaml file my build FINALLY worked fine.

    You may need to recycle the agent / controller from within the TFS tool.

    enter image description here