csproj tweaks to support app publish

remotes/1695061714407202320/main
cosmonaut 2023-05-22 18:28:13 -07:00
parent 300ef9f88e
commit adeba633e5
2 changed files with 4 additions and 7 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks> <TargetFramework>net7.0</TargetFramework>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>11</LangVersion> <LangVersion>11</LangVersion>
@ -22,6 +22,7 @@
<ItemGroup> <ItemGroup>
<None Include="MoonWorks.dll.config"> <None Include="MoonWorks.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -97,16 +97,12 @@ namespace MoonWorks
// Get the path to the assembly // Get the path to the assembly
Assembly assembly = Assembly.GetExecutingAssembly(); Assembly assembly = Assembly.GetExecutingAssembly();
string assemblyPath = ""; string assemblyPath = System.AppContext.BaseDirectory;
if (assembly.Location != null)
{
assemblyPath = Path.GetDirectoryName(assembly.Location);
}
// Locate the config file // Locate the config file
string xmlPath = Path.Combine( string xmlPath = Path.Combine(
assemblyPath, assemblyPath,
assembly.GetName().Name + ".dll.config" "MoonWorks.dll.config"
); );
if (!File.Exists(xmlPath)) if (!File.Exists(xmlPath))
{ {