9

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.

Baahubali
  • 4,604
  • 6
  • 33
  • 72
  • Which build are you using ? XAML or vNext build ? Could you add more detail info for troubleshooting, such as detail log and your environment. – PatrickLu-MSFT Jun 06 '17 at 10:29
  • I am using XAML build. – Baahubali Jun 08 '17 at 03:35
  • 1
    Hey @Patrick-MSFT what version of msbuild does XAML use to build and can you set the version like you can in the vNext build? I remember the build config dialog in VS has a bunch of settings for msbuild, but I can't remember if there is a way to set the path TFSBuild uses to set where msbuild is run from... Could this be the case in this instance? – Michael Coxon Jun 08 '17 at 14:24

2 Answers2

6

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

Baahubali
  • 4,604
  • 6
  • 33
  • 72
2

when i check in my code, the build server throws an error, seems you are using a CI build. You could also give a try with manually queue the build. And build your code in local to narrow down if it's related to your TFS environment or not.

Also take a look at event view in the build agent/server, if there are some useful info.

Error BC30037: Character is not valid without TFxxxx may related to your code or syntax.

  • Check to see if an extra character has accidentally been inserted into the programming element.
  • Check that the programming element is spelled or constructed using only characters that are valid for that kind of element

Character is not valid

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • 1
    investigating more, looks like build server is using MsBuild 12 or earlier to do the build and you msbuild version 14.0 or above to build string interpolation correctly. i set MSBuildArguments Property to /p:VisualStudioVersion=14.0 and also changed the TFSBuild.proj file and changed this line to "" but same issue is happening. – Baahubali Jun 08 '17 at 03:35
  • @Baahubali Sorry for the later reply. This is an old issue in TFS XAML build. The process template always point to the wrong msbuild version 12.0 instead of 14.0 when building .net4.6/c#6.0. There are many solutions to this problem. Such as https://stackoverflow.com/questions/32659106/tfs-2013-building-net-4-6-c-sharp-6-0/32691755#32691755. Seems your issue have been solved. Glad to that, always better when you fix it yourself; as you understand how it works!:) – PatrickLu-MSFT Jun 09 '17 at 03:20