Skip to content

Commit c606cc8

Browse files
committed
Update mono, deploy works on rio
1 parent 5ba1265 commit c606cc8

File tree

8 files changed

+123
-93
lines changed

8 files changed

+123
-93
lines changed

src/FRC.CLI.Common/CodeDeployer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task DeployCode()
3636
// Check image
3737
//await m_roboRioImageProvider.CheckCorrectImageAsync().ConfigureAwait(false);
3838

39-
//await m_roboRioDependencyCheckerProvider.CheckIfDependenciesAreSatisfiedAsync().ConfigureAwait(false);
39+
await m_roboRioDependencyCheckerProvider.CheckIfDependenciesAreSatisfiedAsync().ConfigureAwait(false);
4040

4141
await m_nativePackageDeploymentProvider.DeployNativeContentAsync().ConfigureAwait(false);
4242

src/FRC.CLI.Common/DeployProperties.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public static class DeployProperties
3232
//--debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:55555
3333
public const string RobotCommandDebugFileName = "robotDebugCommand";
3434

35-
public const string RobotCommand = "env LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/frc/lib mono \"" + DeployDir + "/{0}\"";
35+
public const string RobotCommand = "env MONO_THREADS_SUSPEND=coop mono \"" + DeployDir + "/{0}\"";
3636

3737
public const string RobotCommandFileName = "robotCommand";
3838

39-
public const string MonoMd5 = "1852022171552091945152452461853193134197150";
39+
public const string MonoMd5 = "769F3315B11F2A78A33EAFDC50FB2410";
4040

41-
public const string MonoVersion = "Mono4.2.1.zip";
41+
public const string MonoZipName = "Mono6.8.0.96-2020-0.zip";
4242

43-
public const string MonoUrl = "https://dl.bintray.com/robotdotnet/Mono/";
43+
public const string MonoUrl = "https://github.com/robotdotnet/Mono-Releases/releases/download/v6.8.0.96-2020-0/Mono6.8.0.96-2020-0.zip";
4444
}
4545
}

src/FRC.CLI.Common/Implementations/Md5HashCheckerProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Md5HashCheckerProvider : IMd5HashCheckerProvider
88
public async Task<bool> VerifyMd5Hash(string file, string hash)
99
{
1010
string? sum = await MD5Helper.Md5SumAsync(file).ConfigureAwait(false);
11-
return sum != null && sum == hash;
11+
return sum != null && sum.Equals(hash, System.StringComparison.InvariantCultureIgnoreCase);
1212
}
1313
}
1414
}

src/FRC.CLI.Common/Implementations/MonoRuntimeProvider.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class MonoRuntimeProvider : IRuntimeProvider
1515
private readonly IMd5HashCheckerProvider m_md5HashCheckerProvider;
1616
private readonly IOutputWriter m_outputWriter;
1717

18-
public string MonoVersion = DeployProperties.MonoVersion;
18+
public string MonoZipName = DeployProperties.MonoZipName;
1919
public string MonoUrl = DeployProperties.MonoUrl;
2020

2121
public string MonoMd5 = DeployProperties.MonoMd5;
@@ -48,16 +48,16 @@ public async System.Threading.Tasks.Task DownladRuntimeAsync()
4848
{
4949
await m_outputWriter.WriteLineAsync("Downloading Mono Runtime").ConfigureAwait(false);
5050
string monoFolder = await GetMonoFolderAsync().ConfigureAwait(false);
51-
string monoFilePath = Path.Combine(monoFolder, MonoVersion);
51+
string monoFilePath = Path.Combine(monoFolder, MonoZipName);
5252
if (await m_md5HashCheckerProvider.VerifyMd5Hash(monoFilePath, MonoMd5).ConfigureAwait(false))
5353
{
5454
// File already exists and is correct. No need to redownload
5555
await m_outputWriter.WriteLineAsync("Runtime already downloaded. Skipping...").ConfigureAwait(false);
5656
return;
5757
}
5858
Directory.CreateDirectory(monoFolder);
59-
string file = Path.Combine(monoFolder, MonoVersion);
60-
await DownloadToFileAsync(MonoUrl + MonoVersion, file).ConfigureAwait(false);
59+
string file = Path.Combine(monoFolder, MonoZipName);
60+
await DownloadToFileAsync(MonoUrl, file).ConfigureAwait(false);
6161
if (!await m_md5HashCheckerProvider.VerifyMd5Hash(monoFilePath, MonoMd5).ConfigureAwait(false))
6262
{
6363
throw m_exceptionThrowerProvider.ThrowException("Mono file not downloaded successfully");
@@ -74,7 +74,7 @@ public virtual async Task<string> GetMonoFolderAsync()
7474
public async System.Threading.Tasks.Task InstallRuntimeAsync()
7575
{
7676
string monoFolder = await GetMonoFolderAsync().ConfigureAwait(false);
77-
string monoFilePath = Path.Combine(monoFolder, MonoVersion);
77+
string monoFilePath = Path.Combine(monoFolder, MonoZipName);
7878
await InstallRuntimeAsync(monoFilePath).ConfigureAwait(false);
7979
}
8080

src/dotnet-frc/Commands/RuntimeCommand.cs

+108-78
Original file line numberDiff line numberDiff line change
@@ -57,86 +57,116 @@ public RuntimeCommand() : base("runtime", "Installs the runtime on the robot")
5757

5858
public async Task<int> HandleCommand(int team, string? project, bool download, bool install, string? location)
5959
{
60-
;
60+
var msBuild = ResolveProject(project);
61+
if (msBuild == null)
62+
{
63+
64+
return -1;
65+
}
66+
var builder = new ContainerBuilder();
67+
AutoFacUtilites.AddCommonServicesToContainer(builder, msBuild, team, false,
68+
false);
69+
var container = builder.Build();
70+
71+
using (var scope = container.BeginLifetimeScope())
72+
{
73+
var runtimeProvider = scope.Resolve<IRuntimeProvider>();
74+
if (download)
75+
{
76+
await runtimeProvider.DownladRuntimeAsync();
77+
}
78+
79+
if (install)
80+
{
81+
if (location != null)
82+
{
83+
await runtimeProvider.InstallRuntimeAsync(location);
84+
}
85+
else
86+
{
87+
await runtimeProvider.InstallRuntimeAsync();
88+
}
89+
}
90+
}
91+
6192
return 0;
62-
;
6393
}
6494

65-
// private CommandOption _downloadOption;
66-
// private CommandOption _installOption;
67-
// private CommandOption _locationOption;
68-
//#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
69-
70-
// public static DotNetSubCommandBase Create()
71-
// {
72-
// var command = new RuntimeCommand
73-
// {
74-
// Name = "runtime",
75-
// Description = "Installs the runtime on the robot",
76-
// HandleRemainingArguments = false
77-
// };
78-
79-
// SetupBaseOptions(command);
80-
81-
// command._downloadOption = command.Option(
82-
// "-d|--download",
83-
// "Download the runtime",
84-
// CommandOptionType.NoValue
85-
// );
86-
87-
// command._installOption = command.Option(
88-
// "-i|--install",
89-
// "Install the runtime",
90-
// CommandOptionType.NoValue
91-
// );
92-
93-
// command._locationOption = command.Option(
94-
// "-l|--location",
95-
// "Local runtime location",
96-
// CommandOptionType.SingleValue
97-
// );
98-
99-
// return command;
100-
// }
101-
102-
//public override async Task<int> RunAsync(string fileOrDirectory)
103-
//{
104-
// var builder = new ContainerBuilder();
105-
// AutoFacUtilites.AddCommonServicesToContainer(builder, fileOrDirectory, this,
106-
// false);
107-
// builder.RegisterType<MonoRuntimeProvider>().As<IRuntimeProvider>();
108-
// var container = builder.Build();
109-
110-
// using (var scope = container.BeginLifetimeScope())
111-
// {
112-
// if (!_downloadOption.HasValue() && !_installOption.HasValue())
113-
// {
114-
// throw scope.Resolve<IExceptionThrowerProvider>().ThrowException(
115-
// "No argument specified. Must provide an argument to use"
116-
// );
117-
// }
118-
119-
// var runtimeProvider = scope.Resolve<IRuntimeProvider>();
120-
// if (_downloadOption.HasValue())
121-
// {
122-
// await runtimeProvider.DownladRuntimeAsync();
123-
// }
124-
125-
// if (_installOption.HasValue())
126-
// {
127-
// if (_locationOption.HasValue())
128-
// {
129-
// await runtimeProvider.InstallRuntimeAsync(_locationOption.Value());
130-
// }
131-
// else
132-
// {
133-
// await runtimeProvider.InstallRuntimeAsync();
134-
// }
135-
// }
136-
// }
137-
138-
// return 0;
139-
//}
140-
95+
// private CommandOption _downloadOption;
96+
// private CommandOption _installOption;
97+
// private CommandOption _locationOption;
98+
//#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
99+
100+
// public static DotNetSubCommandBase Create()
101+
// {
102+
// var command = new RuntimeCommand
103+
// {
104+
// Name = "runtime",
105+
// Description = "Installs the runtime on the robot",
106+
// HandleRemainingArguments = false
107+
// };
108+
109+
// SetupBaseOptions(command);
110+
111+
// command._downloadOption = command.Option(
112+
// "-d|--download",
113+
// "Download the runtime",
114+
// CommandOptionType.NoValue
115+
// );
116+
117+
// command._installOption = command.Option(
118+
// "-i|--install",
119+
// "Install the runtime",
120+
// CommandOptionType.NoValue
121+
// );
122+
123+
// command._locationOption = command.Option(
124+
// "-l|--location",
125+
// "Local runtime location",
126+
// CommandOptionType.SingleValue
127+
// );
128+
129+
// return command;
130+
// }
131+
132+
//public override async Task<int> RunAsync(string fileOrDirectory)
133+
//{
134+
// var builder = new ContainerBuilder();
135+
// AutoFacUtilites.AddCommonServicesToContainer(builder, fileOrDirectory, this,
136+
// false);
137+
// builder.RegisterType<MonoRuntimeProvider>().As<IRuntimeProvider>();
138+
// var container = builder.Build();
139+
140+
// using (var scope = container.BeginLifetimeScope())
141+
// {
142+
// if (!_downloadOption.HasValue() && !_installOption.HasValue())
143+
// {
144+
// throw scope.Resolve<IExceptionThrowerProvider>().ThrowException(
145+
// "No argument specified. Must provide an argument to use"
146+
// );
147+
// }
148+
149+
// var runtimeProvider = scope.Resolve<IRuntimeProvider>();
150+
// if (_downloadOption.HasValue())
151+
// {
152+
// await runtimeProvider.DownladRuntimeAsync();
153+
// }
154+
155+
// if (_installOption.HasValue())
156+
// {
157+
// if (_locationOption.HasValue())
158+
// {
159+
// await runtimeProvider.InstallRuntimeAsync(_locationOption.Value());
160+
// }
161+
// else
162+
// {
163+
// await runtimeProvider.InstallRuntimeAsync();
164+
// }
165+
// }
166+
// }
167+
168+
// return 0;
169+
//}
170+
141171
}
142172
}

src/dotnet-frc/Properties/launchSettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"dotnet-frc": {
44
"commandName": "Project",
5-
"commandLineArgs": "deploy --project=C:\\Users\\thad.house\\GitHub\\RobotDotNet\\WPILib\\dev\\roboRIODev"
5+
"commandLineArgs": "deploy --project=C:\\Users\\thad.house\\GitHub\\RobotDotNet\\WPILib\\dev\\roboRIODev "
66
}
77
}
88
}

src/dotnet-frc/Utilities/MsBuildProject.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ public string GetProjectAssemblyName()
137137
{
138138
if (item.Name == "AssemblyName")
139139
{
140-
return item.Value + ".exe";
140+
return item.Value + ".dll";
141141
}
142142
}
143-
return Path.GetFileNameWithoutExtension(ProjectFile) + ".exe";
143+
return Path.GetFileNameWithoutExtension(ProjectFile) + ".dll";
144144
}
145145

146146
public MsBuildProject? GetPropsFile()

test/FRC.CLI.Common.Test/MonoRuntimeProviderTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public async Task TestInstallRuntimeMain()
146146
sut.Verify(x => x.InstallRuntimeAsync(It.IsAny<string>()), Times.Once);
147147
Assert.Equal(1, count);
148148
Assert.NotNull(str);
149-
Assert.Equal(Path.Combine(tempPath, "mono", DeployProperties.MonoVersion), str);
149+
Assert.Equal(Path.Combine(tempPath, "mono", DeployProperties.MonoZipName), str);
150150
}
151151
}
152152
}

0 commit comments

Comments
 (0)