Skip to content

Commit

Permalink
WPILib and VSCode download works now. Close #12
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSinn committed Feb 11, 2019
1 parent 2a9d624 commit e1e55df
Show file tree
Hide file tree
Showing 9 changed files with 297 additions and 36 deletions.
10 changes: 5 additions & 5 deletions CSAUSBTool/CSAUSBTool.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions CSAUSBTool/CSAUSBTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand All @@ -22,16 +23,20 @@ public partial class CSAUSBTool : Form

public CSAUSBTool(string[] args)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
InitializeComponent();

if (args.Length >= 1)
{
Console.Out.WriteLine(args[0]);
competitions[9999] = new FRCYear(9999, FRCYear.GetWebList(args[0]));
}

competitions[2019] = new FRCYear(2019, FRCYear.GetWebList(2019));
competitions[2018] = new FRCYear(2018, FRCYear.GetWebList(2018));
competitions[2017] = new FRCYear(2017, FRCYear.GetWebList(2017));

buildISOButton.Enabled = false;
yearSelection.DataSource = new BindingSource(competitions, null);
yearSelection.DisplayMember = "Key";
Expand Down Expand Up @@ -98,5 +103,10 @@ private void buildISOButton_Click(object sender, EventArgs e)
selectedFrc.BuildISO(downloadFolderPath, isoFolderPath, toolStripProgressBar);
toolStripStatusLabel.Text = @"Idle";
}

public static ToolStripProgressBar GetProgressBar()
{
return toolStripProgressBar;
}
}
}
25 changes: 13 additions & 12 deletions CSAUSBTool/CSAUSBTool.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.3.2.2\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.2.2\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -56,13 +57,8 @@
<StartupObject>CSAUSBTool.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="DiscUtils, Version=0.13.0.0, Culture=neutral, PublicKeyToken=5fa5b410cc9c6289, processorArchitecture=MSIL">
<HintPath>..\packages\DiscUtils.0.13.0-alpha\lib\net45\DiscUtils.dll</HintPath>
<Private>True</Private>
<Reference Include="Costura, Version=3.2.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.3.2.2\lib\net40\Costura.dll</HintPath>
</Reference>
<Reference Include="DiscUtils.BootConfig, Version=0.13.0.0, Culture=neutral, PublicKeyToken=5fa5b410cc9c6289, processorArchitecture=MSIL">
<HintPath>..\packages\DiscUtils.BootConfig.0.13.0-alpha\lib\net45\DiscUtils.BootConfig.dll</HintPath>
Expand Down Expand Up @@ -175,6 +171,9 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -194,6 +193,7 @@
<DependentUpon>CSAUSBTool.cs</DependentUpon>
</Compile>
<Compile Include="FRCYear.cs" />
<Compile Include="HttpClientDownload.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="CSAUSBTool.resx">
Expand Down Expand Up @@ -225,7 +225,9 @@
<ItemGroup>
<Content Include=".gitignore" />
<Content Include="firstrobotics_iconvert_rgb_tCt_icon.ico" />
<None Include="FodyWeavers.xml" />
<None Include="FodyWeavers.xml">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
Expand All @@ -240,15 +242,14 @@
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.2.0.0\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.2.0.0\build\dotnet\Fody.targets')" />
<Import Project="..\packages\Fody.3.3.5\build\Fody.targets" Condition="Exists('..\packages\Fody.3.3.5\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.2.0.0\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.0.0\build\dotnet\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.3.3.5\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.3.5\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.3.2.2\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.2.2\build\Costura.Fody.props'))" />
</Target>
<Import Project="..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.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">
Expand Down
56 changes: 42 additions & 14 deletions CSAUSBTool/ControlSystemsSoftware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
using System.Net;
using System.Security.Cryptography;
using System.IO.Compression;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CSAUSBTool
{
Expand All @@ -28,7 +31,7 @@ public ControlSystemsSoftware(string name, string fileName, string url, string h
Unzip = unzip;
}

public void Download(string path, DownloadProgressChangedEventHandler progress, bool async)
public async void Download(string path, DownloadProgressChangedEventHandler progress, bool async)
{
if (FileName == "") return;
if (Uri.ToString().StartsWith("local:"))
Expand All @@ -37,23 +40,48 @@ public void Download(string path, DownloadProgressChangedEventHandler progress,
return;
}

using (WebClient client = new WebClient())
if (FileName.Contains("VSCode") || FileName.Contains("WPILib"))
{
client.DownloadProgressChanged += progress;
await DownloadHTTP(path);
}
else
{
using (WebClient client = new WebClient())
{
client.DownloadProgressChanged += progress;

client.DownloadFileCompleted += (sender, eventargs) =>
{
Console.Out.WriteLine("Download finished for: " + Name);
};
if (async)
client.DownloadFileAsync(Uri, path + @"\" + FileName);
else
{
client.DownloadFile(Uri, path + @"\" + FileName);
Console.Out.WriteLine("Download finished for: " + Name);
Thread.Sleep(1000);
IsValid(path);
}
}
}
}

client.DownloadFileCompleted += (sender, eventargs) =>
async Task DownloadHTTP(string path)
{
var noCancel = new CancellationTokenSource();

using (var client = new HttpClientDownloadWithProgress(Uri.ToString(), path + @"\" + FileName))
{
client.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) =>
{
Console.Out.WriteLine("Download finished for: " + Name);
if (progressPercentage != null)
{
CSAUSBTool.toolStripProgressBar.Value = (int)progressPercentage;
}
};
if (async)
client.DownloadFileAsync(Uri, path + @"\" + FileName);
else
{
client.DownloadFile(Uri, path + @"\" + FileName);
Console.Out.WriteLine("Download finished for: " + Name);
Thread.Sleep(1000);
IsValid(path);
}

await client.StartDownload(noCancel.Token);
}
}

Expand Down
2 changes: 2 additions & 0 deletions CSAUSBTool/FRCYear.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
Expand Down Expand Up @@ -118,5 +119,6 @@ public override string ToString()
{
return Year + "";
}

}
}
4 changes: 2 additions & 2 deletions CSAUSBTool/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>
</Weavers>
111 changes: 111 additions & 0 deletions CSAUSBTool/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
Loading

0 comments on commit e1e55df

Please sign in to comment.