Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

Commit

Permalink
Exclude appsettings.json and simconnect.lib from single file publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Oceanswave committed Sep 12, 2020
1 parent 5e7df8e commit 1031175
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 37 deletions.
27 changes: 27 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/FSMosquitoClient.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
42 changes: 42 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/FSMosquitoClient.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/FSMosquitoClient.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/FSMosquitoClient.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
23 changes: 12 additions & 11 deletions FSMosquitoClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.8" />
<PackageReference Include="MQTTnet" Version="3.0.12" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
Expand Down Expand Up @@ -54,16 +55,16 @@
</ItemGroup>

<ItemGroup>
<None Update="lib\Microsoft.FlightSimulator.SimConnect.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\SimConnect.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="REM xcopy &quot;$(ProjectDir)lib\SimConnect.dll&quot; &quot;$(OutDir)&quot; /Y&#xD;&#xA;" />
<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
<Copy SourceFiles="lib\SimConnect.dll" DestinationFolder="$(OutDir)" />
</Target>
<Target Name="CopyCustomContentOnPublish" AfterTargets="Publish">
<Copy SourceFiles="lib\SimConnect.dll" DestinationFolder="$(PublishDir)" />
</Target>

</Project>
3 changes: 2 additions & 1 deletion FsMqtt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ private async Task OnDisconnected(MqttClientDisconnectedEventArgs e)
await MqttClient.ConnectAsync(_mqttClientOptions, CancellationToken.None);
return;
}
catch
catch(Exception ex)
{
_logger.LogInformation($"Reconnection failed.");
_logger.LogError($"Exception thrown on Reconnect: {ex.Message}", ex);
}

_logger.LogInformation($"Disconnected from {_serverUrl}.");
Expand Down
11 changes: 0 additions & 11 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,6 @@ static void Main(string[] args)

_logger.LogInformation("Starting FSMosquitoClient...");

// Ensure that SimConnect.dll exists in the current folder.
if (!File.Exists("./SimConnect.dll"))
{
_logger.LogInformation("SimConnect.dll did not exist. Adding SimConnect.dll from resource.");
File.WriteAllBytes("./SimConnect.dll", Resources.SimConnect);
}
else
{
_logger.LogInformation("SimConnect.dll already exists. Continuing.");
}

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Expand Down
10 changes: 0 additions & 10 deletions Properties/Resources.Designer.cs

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

3 changes: 0 additions & 3 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,4 @@
<data name="mosquito" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\mosquito.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SimConnect" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\lib\SimConnect.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
2 changes: 1 addition & 1 deletion appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"fs_mosquito_serverurl": "wss://localhost:8443/mqtt/ws",
"fs_mosquito_clientid": "some_pilot",
"fs_mosquito_serverurl": "ws://localhost:8080/mqtt/ws",
"fs_mosquito_username": "guest",
"fs_mosquito_password": "guest"
}

0 comments on commit 1031175

Please sign in to comment.