0
votes

I have following errors on Azure DevOps:

Floow.Admin.Domain.Attributes\ServiceDocumentFieldAttribute.cs(38,30): Error CS1002: ; expected Floow.Admin.Domain.Attributes\ServiceDocumentFieldAttribute.cs(38,43): Error CS1519: Invalid token '(' in class, struct, or interface member declaration

It is about following code

public class GridFilterAttribute : Attribute
{
    public readonly string[] Fields;
    public bool IsFilter => Fields.Any();
    public GridFilterAttribute(params string[] fields)
    {
        Fields = fields;
    }        
}

Could this have to do with the C# version? Local no problems.

########################## New information ##########################

Could this be a reason: ##error]packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.3.6.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets(48,5): Error MSB4062: The "KillProcess" task could not be loaded from the assembly c:\agent\2\s\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.3.6.0\build\net46....\tasks\DotNetCompilerPlatformTasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

2
Is this .net or .net core? Are you defining the c# language version in the csproj file? are you building on windows or linux build agent? Can you confirm which line of your code 38 is? And finally, are you 100% sure that the same version of the code is being used by the build server (i.e. your local git commit hash matches that used by the build server)?Carl
.net framework 4.6.2 / c# version is set by framework version / windows build agent / line 38: public bool IsFilter => Fields.Any(); / yes I am ------ Is this clear to you (formatting text in comments is not nice)?Roel Alblas
Is there a difference between msbuild version on your local and the build server?Carl
Can you show your pipeline? Did you restore nuget packages?Krzysztof Madej

2 Answers

1
votes

Compiler Error CS1519

Invalid token 'token' in class, struct, or interface member declaration

This error is generated whenever a token is encountered in a location where it does not belong. A token is a keyword; an identifier (the name of a class, struct, method, and so on); a string, character, or numeric literal value such as 108, "Hello", or 'A'; or an operator or punctuator such as == or ;.

Any class, struct, or interface member declaration that contains invalid modifiers before the type will generate this error. To fix the error, remove the invalid modifiers.

The following sample generates CS1519 in five places because tokens are placed in locations where they are not valid:

// CS1519.cs  
// Generates CS1519 because a class name cannot be a number:  
class Test 42
{  
// Generates CS1519 because of 'j' following 'I'  
// with no comma between them:  
    int i j;
// Generates CS1519 because of "checked" on void method:  
    checked void f4();
  
// Generates CS1519 because of "num":  
    void f5(int a num){}
  
// Generates CS1519 because of namespace inside class:  
    namespace;
  
}

So, check out for misplaced tokens in your ServiceDocumentFieldAttribute.cs.

0
votes

The build server was down. Because we are isolated because of Corona we didn't notice. Now moving to a VPS so we always can access the server. Weird there is no server down error.