Having issues trying to compile thrive (dotnet restore)

When trying to use dotnet restore in visual studio I get this error

Strangely this used to work without any issues before I got a new pc

From the error:

The project file "C:\Program Files\Git\Thrive\RevolutionaryGamesCommon\ScriptsBase\ScriptsBase.csproj" was not found.

That seems to indicate to me that you didn’t initialize the git submodules. Which is a new thing I recently tried to let everyone know will be a requirement going forward: Major changes to Thrive repository structure and scripts - Programming - Thrive Development Forum

The setup instructions have been updated with info regarding this. Here’s the submodule init command recommended in there: git submodule update --init --recursive

Dotnet restore works now, but when I try to use the build button I get a bunch of errors like this

C:\Program Files\Git\Thrive\RevolutionaryGamesCommon\SharedBase\ModelVerifiers\EmailAttribute.cs(58,2): } expected

Only thing I can think of is that the file is for some reason cutoff or broken in the copy you have. The last closing brace } is on the line 58 of that file.

Here’s the entire file in vs

namespace SharedBase.ModelVerifiers;

using System;
using System.ComponentModel.DataAnnotations;
using Utilities;

/// <summary>
///   Basic validation that (if not null) that a string looks like an email
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class EmailAttribute : RequiredAttribute
{
    protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
    {
        // Allow null values
        if (ReferenceEquals(value, null))
            return ValidationResult.Success;

        var asString = value as string;

        if (asString == null)
        {
            throw new InvalidOperationException(
                $"Can't apply {nameof(EmailAttribute)} to a non-string type");
        }

        var atIndex = asString.IndexOf('@');

        if (atIndex < 1 || atIndex + 1 >= asString.Length)
        {
            return new ValidationResult(
                ErrorMessage ??
                $"The {validationContext.DisplayName} field must be an email address" +
                "(missing @ character at valid position).",
                new[] { validationContext.MemberName! });
        }

        if (asString.Length is > GlobalConstants.MaxEmailLength or < GlobalConstants.MinEmailLength)
        {
            return new ValidationResult(
                ErrorMessage ??
                $"The {validationContext.DisplayName} field must be an email address" +
                "(address is too long or too short).",
                new[] { validationContext.MemberName! });
        }

        if (!asString.Trim().Equals(asString))
        {
            return new ValidationResult(
                ErrorMessage ??
                $"The {validationContext.DisplayName} field must be an email address" +
                "(there is trailing or preceding whitespace).",
                new[] { validationContext.MemberName! });
        }

        return ValidationResult.Success;
    }
}

It has 2 errors ( { expected; } expected ) at line 1 and 58
The error goes away after I put { after ModelVerifiers and } at line 58

I also get a namespace definition error

Rather than posting the file, you can use git to check that the file is correct. But quickly looking at the end it does look correct.

Though now reading that reminds me that it uses the file level namespace definition. So my guess now is that you have too old of a C# compiler you are using on Thrive so it doesn’t understand that syntax.

This sounds much more significant than the expected { error and leads me to believe my theory about the file namespace new syntax being the problem is likely correct.

Yeah, looks like I do have an outdated .net version

The latest one is 6.0.9 and I have 6.0.109

I have the same version. Are you perhaps accidentally building with mono or something? When building with Godot you need to select dotnet as the build tool.

Try running dotnet build in the Thrive folder if you weren’t building that way.

1 Like

Ah, I was using VS build tools

I was pretty sure I changed it, it’s fixed now (Built with no errors)

1 Like

That’d probably also work as long you have a new enough version of that to have a C# 10 compiler, but using dotnet to build seems much more reliable and works well both on Windows and Linux (and I think mac as well but haven’t really done much there).

Only dotnet works for me so Idk

But do you know what version of VS build tools you have? And what’s the latest one?
Also some people have had problems in the past where they have like 8 years old C# compiler in their PATH first that gets picked with the build not using dotnet command.

I’m curious to know whether we should consider adding advice on the setup instructions to avoid that like the plague.

I don’t even use VS code so I do not have vs build tools

I think I might have accidentally changed it to vs build tools in the settings earlier on

As the build does something you probably have some C# compiler installed years ago in a random place that it finds.