Fix script errors

This commit is contained in:
NGnius (Graham) 2020-05-03 15:21:40 -04:00
parent 4e5cc40be4
commit f244eb9683
2 changed files with 14 additions and 17 deletions

View file

@ -10,7 +10,7 @@ def getAssemblyReferences(path):
asmDir = Path(path) asmDir = Path(path)
result = list() result = list()
for child in asmDir.iterdir(): for child in asmDir.iterdir():
if child.is_file() and re.search(DLL_EXCLUSIONS_REGEX, str(child), re.I) is None: if child.is_file() and re.search(DLL_EXCLUSIONS_REGEX, str(child), re.I) is None and str(child).lower().endswith(".dll"):
result.append(str(child).replace("\\", "/")) result.append(str(child).replace("\\", "/"))
return result return result
@ -24,8 +24,7 @@ def buildReferencesXml(path):
+ " <HintPath>..\\" + asmPath.replace("/", "\\") + "</HintPath>\n" \ + " <HintPath>..\\" + asmPath.replace("/", "\\") + "</HintPath>\n" \
+ " </Reference>\n" + " </Reference>\n"
result.append(xml) result.append(xml)
return "".join(result) return "<!--Start Dependencies-->\n <ItemGroup>\n" + "".join(result) + " </ItemGroup>\n<!--End Dependencies-->"
#return "<!--Start Dependencies-->\n <ItemGroup>\n" + "".join(result) + " </ItemGroup>\n<!--End Dependencies-->"
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate GamecraftModdingAPI.csproj") parser = argparse.ArgumentParser(description="Generate GamecraftModdingAPI.csproj")
@ -34,22 +33,21 @@ if __name__ == "__main__":
print("Building Assembly references") print("Building Assembly references")
asmXml = buildReferencesXml("../ref/Gamecraft_Data/Managed") asmXml = buildReferencesXml("../ref/Gamecraft_Data/Managed")
print(asmXml) # print(asmXml)
with open("../GamecraftModdingAPI/GamecraftModdingAPI.csproj", "r") as xmlFile: with open("../GamecraftModdingAPI/GamecraftModdingAPI.csproj", "r") as xmlFile:
print("Parsing GamecraftModdingAPI.csproj") print("Parsing GamecraftModdingAPI.csproj")
fileStr = xmlFile.read() fileStr = xmlFile.read()
print(fileStr) # print(fileStr)
depsStart = re.search(r"\<!--\s*Start\s+Dependencies\s*--\>", fileStr) depsStart = re.search(r"\<!--\s*Start\s+Dependencies\s*--\>", fileStr)
depsEnd = re.search(r"\<!--\s*End\s+Dependencies\s*--\>", fileStr) depsEnd = re.search(r"\<!--\s*End\s+Dependencies\s*--\>", fileStr)
if depsStart is None or depsEnd is None: if depsStart is None or depsEnd is None:
print("Unable to find dependency XML comments, aborting!") print("Unable to find dependency XML comments, aborting!")
exit(1) exit(1)
newFileStr = fileStr[:depsStart.end()] + "\n" + asmXml + "\n" + fileStr[depsEnd.start():] newFileStr = fileStr[:depsStart.start()] + "\n" + asmXml + "\n" + fileStr[depsEnd.end() + 1:]
with open("../GamecraftModdingAPI/GamecraftModdingAPI.csproj", "w") as xmlFile: with open("../GamecraftModdingAPI/GamecraftModdingAPI.csproj", "w") as xmlFile:
print("Writing Assembly references (not)") print("Writing Assembly references (not)")
#xmlFile.seek(0)
xmlFile.write(newFileStr) xmlFile.write(newFileStr)
print(newFileStr) # print(newFileStr)

View file

@ -16,24 +16,23 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Lib.Harmony" Version="1.2.0.1" /> <PackageReference Include="Lib.Harmony" Version="1.2.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<!--Start Dependencies--> <!--Start Dependencies-->
<ItemGroup>
<Reference Include="IllusionInjector"> <Reference Include="IllusionInjector">
<HintPath>..\ref\Gamecraft_Data\Managed\IllusionInjector.dll</HintPath> <HintPath>..\ref\Gamecraft_Data\Managed\IllusionInjector.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\IllusionInjector.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\IllusionInjector.dll</HintPath>
</Reference> </Reference>
<Reference Include="IllusionInjector.pdb">
<HintPath>..\ref\Gamecraft_Data\Managed\IllusionInjector.pdb</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\IllusionInjector.pdb</HintPath>
</Reference>
<Reference Include="IllusionPlugin"> <Reference Include="IllusionPlugin">
<HintPath>..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll</HintPath> <HintPath>..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll</HintPath>
</Reference> </Reference>
<Reference Include="IllusionPlugin.pdb">
<HintPath>..\ref\Gamecraft_Data\Managed\IllusionPlugin.pdb</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\IllusionPlugin.pdb</HintPath>
</Reference>
<Reference Include="JWT"> <Reference Include="JWT">
<HintPath>..\ref\Gamecraft_Data\Managed\JWT.dll</HintPath> <HintPath>..\ref\Gamecraft_Data\Managed\JWT.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\JWT.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\JWT.dll</HintPath>
@ -806,7 +805,7 @@
<HintPath>..\ref\Gamecraft_Data\Managed\VisualProfiler.dll</HintPath> <HintPath>..\ref\Gamecraft_Data\Managed\VisualProfiler.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\VisualProfiler.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\VisualProfiler.dll</HintPath>
</Reference> </Reference>
</ItemGroup>
<!--End Dependencies--> <!--End Dependencies-->
</Project> </Project>