I'm working in an environment in which all projects are placed into a Global Solution irrelevant of the specific business areas of the projects. So the solution is a monstrosity. I'm accustomed to a more segregated approach based on separation of concerns; but that's irrelevant to the question.
One of the projects in this solution was written in VB.NET and there is a section of code which is using the #Disable
and #Enable
directives as described here
According to Microsoft the directives are valid and if I perform a specific build within Visual Studio against the project containing these directives; I get a successful build.
However, this organization requires a preliminary successful build using MSBuild from a command prompt to ensure that it will build on the build server. Which I cannot get because MSBuild reports:
error BC30248: 'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected.
Here is the actual code block that is throwing the error:
Protected Overrides Function ConvertToString() As IOperand
#Disable Warning BC42322
Return MyValue.ToString()
#Enable Warning BC42322
End Function
The best I can conclude is that there must be some MSBuild optional flag that needs to be set prior to performing the build to accomodate for this and prevent the error or these directives are deprecated. Not 100% certain which is the case though (if either) but I do need to get the code to build successfully under MSBuild.
If they were warnings, I could simply ignore them but hence it is not the case.
Also, I've already tried using different versions via the /p:VisualStudioVersion switch. The results are all the same.