Philipp15b / go-steam

Steam's protocol in Go to allow automation of different actions on the Steam network without running an actual Steam client. Includes APIs for friends, chatting, trading, trade offers and TF2 crafting.
https://pkg.go.dev/github.com/Philipp15b/go-steam/v3
Other
387 stars 131 forks source link

Updating go-steam to a new SteamKit version fails #98

Closed Nuc1eoN closed 5 years ago

Nuc1eoN commented 5 years ago

I am trying to update to a new SteamKit version now, but the build fails:

$ go run generator.go clean proto steamlang
# Cleaning
# Building Steam Language
# Building Protobufs
> [libprotobuf WARNING google/protobuf/compiler/parser.cc:564] No syntax specified for the proto file: steammessages_parental.steamclient.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
> [libprotobuf WARNING google/protobuf/compiler/parser.cc:564] No syntax specified for the proto file: steammessages_unified_base.steamclient.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
> [libprotobuf WARNING google/protobuf/compiler/parser.cc:564] No syntax specified for the proto file: google/protobuf/descriptor.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
> panic: runtime error: index out of range

goroutine 1 [running]:
main.cutAllSubmatch(0xc0000ce090, 0xc000176000, 0xeac0, 0xecc0, 0x1, 0x2, 0xc000024080, 0x0)
        /home/nuc/go/src/github.com/Philipp15b/go-steam/generator/generator.go:227 +0xe2
main.fixProto(0xc0000aa180, 0x2b)
        /home/nuc/go/src/github.com/Philipp15b/go-steam/generator/generator.go:196 +0x530
main.buildProtoMap(0x5301a6, 0xb, 0xc000096270, 0x531a8d, 0x14)
        /home/nuc/go/src/github.com/Philipp15b/go-steam/generator/generator.go:92 +0x195
main.buildProto()
        /home/nuc/go/src/github.com/Philipp15b/go-steam/generator/generator.go:82 +0xfd
main.main()
        /home/nuc/go/src/github.com/Philipp15b/go-steam/generator/generator.go:37 +0x20e
exit status 2

Btw it might help that https://github.com/faceit/go-steam has some commits for newer SteamKit versions.

Philipp15b commented 5 years ago

I've updated the generator in b356aa0c7c318fb6ecb46a4a8de6e1ca1903575f for updates in protoc-gen-go which were probably the reason for the crash. Now it works with the newest protoc-gen-go.

To update to a new SteamKit version with new steamlang/protobuf files, you'll probably also need to update the file lists in generator.go (as was done in faceit's repo).

Nuc1eoN commented 5 years ago

Thank you so much, that fixed it!

About updating to the new SteamKit version, it seems upsteam SteamKit has also switched the C# framework it is built against, see https://github.com/faceit/go-steam/issues/3

So instead of

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{EBF5B7D5-58F4-4F68-A997-1BE71A72F078}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>SteamLanguageParser</RootNamespace>
    <AssemblyName>SteamLanguageParser</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <StartupObject>
    </StartupObject>
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <OldToolsVersion>3.5</OldToolsVersion>
    <UpgradeBackupLocation />
    <PublishUrl>publish\</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <OutputPath>bin\Debug\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <OutputPath>bin\Release\</OutputPath>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="CodeGenerator.cs" />
    <Compile Include="Generator\JavaGen.cs" />
    <Compile Include="Generator\CSharpGen.cs" />
    <Compile Include="Generator\ObjCGenBase.cs" />
    <Compile Include="Generator\ObjCImplementationGen.cs" />
    <Compile Include="Generator\ObjCInterfaceGen.cs" />
    <Compile Include="Parser\LanguageParser.cs" />
    <Compile Include="Parser\SymbolLocator.cs" />
    <Compile Include="Parser\TokenAnalyzer.cs" />
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
      <Visible>False</Visible>
      <ProductName>Windows Installer 3.1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

SteamLanguageParser.csproj now looks like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

</Project>

So because of that /generator/GoSteamLanguageGenerator/GoSteamLanguageGenerator.csproj probably also needs that adjustment. Unfortunately I am unsure how to to this yet, I am totally unexperienced with .NET

Philipp15b commented 5 years ago

Okay, so after several reboots and .NET framework installations, I managed to update the GoSteamLanguageGenerator code for the new SteamKit version (394218d1e118ac808800b16532bbeac2e7c69163). In c40bffc31b3c4bb736ba0d47404e91b4e759c62c, I regenerated all files.

Finally, I tried to update the handler logic for the protocol changes (b04c5a83c1c0e14f999056ae9f438cd3f0c0ba3f). I have not yet tested if it works now, but at least it compiles 😅.

Nuc1eoN commented 5 years ago

Thanks for taking up the work @Philipp15b !

There was initially an issue when I tried to compile the project on linux:

msbuild GoSteamLanguageGenerator.csproj 
Microsoft (R) Build Engine version 16.0.0.0 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 08/17/2019 17:40:11.
Project "/home/nuc/go/src/github.com/Philipp15b/go-steam/generator/GoSteamLanguageGenerator/GoSteamLanguageGenerator.csproj" on node 1 (default targets).
/usr/lib/mono/msbuild/15.0/bin/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error : Assets file '/home/nuc/go/src/github.com/Philipp15b/go-steam/generator/GoSteamLanguageGenerator/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/nuc/go/src/github.com/Philipp15b/go-steam/generator/GoSteamLanguageGenerator/GoSteamLanguageGenerator.csproj]
Done Building Project "/home/nuc/go/src/github.com/Philipp15b/go-steam/generator/GoSteamLanguageGenerator/GoSteamLanguageGenerator.csproj" (default targets) -- FAILED.

Build FAILED.

"/home/nuc/go/src/github.com/Philipp15b/go-steam/generator/GoSteamLanguageGenerator/GoSteamLanguageGenerator.csproj" (default target) (1) ->
(ResolvePackageAssets target) -> 
  /usr/lib/mono/msbuild/15.0/bin/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error : Assets file '/home/nuc/go/src/github.com/Philipp15b/go-steam/generator/GoSteamLanguageGenerator/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/nuc/go/src/github.com/Philipp15b/go-steam/generator/GoSteamLanguageGenerator/GoSteamLanguageGenerator.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.76

But after finding https://github.com/dotnet/sdk/issues/2347 it seems I just needed the add the /restore parameter like this msbuild GoSteamLanguageGenerator.csproj /restore

Not exactly sure why that's needed but I figured it might be useful information for some guys.

Also this closes the initial issue since the project finally compiles, thanks for taking up the work! ;)

If there are any bugs with this code I guess it would be better to open seprarate issues:)