Skip to content

Commit

Permalink
[.NET] Clean-up project files
Browse files Browse the repository at this point in the history
Ensures that the Cantera native libs and example data files are copied to output directories.
The Cantera project is marked not-packable. We’ll need a separate project that gathers all the native libs and managed assemblies for creating a complete nuget package for upload to NuGet.org
  • Loading branch information
burkenyo authored and speth committed Aug 17, 2022
1 parent e2fabf9 commit fbaa5d1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 31 deletions.
3 changes: 2 additions & 1 deletion interfaces/dotnet/.gitignore
Expand Up @@ -36,4 +36,5 @@ msbuild.wrn
# Visual Studio 2015
.vs/

lib
lib/
content/
12 changes: 1 addition & 11 deletions interfaces/dotnet/Cantera.Examples/Cantera.Examples.csproj
Expand Up @@ -6,21 +6,11 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../Cantera/Cantera.csproj" />

<None Include="../../../data/gri30.yaml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<Target Name="CopyLibraries" AfterTargets="AfterBuild">

<ItemGroup>
<Libraries Include="$([MSBuild]::NormalizePath(../lib/))*" />
</ItemGroup>

<Copy SourceFiles="@(Libraries)" DestinationFolder="$(OutDir)" />
</Target>

</Project>
11 changes: 0 additions & 11 deletions interfaces/dotnet/Cantera.Tests/Cantera.Tests.csproj
Expand Up @@ -21,17 +21,6 @@
</PackageReference>

<ProjectReference Include="../Cantera/Cantera.csproj" />

<None Include="../../../data/gri30.yaml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<Target Name="CopyLibraries" AfterTargets="AfterBuild">

<ItemGroup>
<Libraries Include="$([MSBuild]::NormalizePath(../lib/))*" />
</ItemGroup>

<Copy SourceFiles="@(Libraries)" DestinationFolder="$(OutDir)" />
</Target>

</Project>
20 changes: 13 additions & 7 deletions interfaces/dotnet/Cantera/Cantera.csproj
Expand Up @@ -8,22 +8,28 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>CanteraDotNet</AssemblyName>
<IsPackable>false</IsPackable>

<LibDir>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory)/../lib))</LibDir>
<ContentDir>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory)/../content))</ContentDir>
</PropertyGroup>

<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">
<DefineConstants>IS_WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
<DefineConstants>IS_MACOS</DefineConstants>
<DefineConstants>IS_MACOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">
<DefineConstants>IS_LINUX</DefineConstants>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Cantera.Tests</_Parameter1>
</AssemblyAttribute>
<InternalsVisibleTo Include="Cantera.Tests" />

<None Include="$(LibDir)/*" CopyToOutputDirectory="PreserveNewest"/>

<None Include="$(ContentDir)/**" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Expand All @@ -40,11 +46,11 @@
<GeneratedPath>$([MSBuild]::NormalizePath($(IntermediateOutputPath)/sourcegen/))</GeneratedPath>
</PropertyGroup>

<Exec Command="python3 $(Script) csharp $(GeneratedPath)"/>
<Exec Command="python3 $(Script) csharp $(GeneratedPath)" Condition="'$(GenerateInterop)' == 'true' Or !Exists('$(GeneratedPath)')"/>

<ItemGroup>
<Compile Remove="$(GeneratedPath)*.cs" />
<Compile Include="$(GeneratedPath)*.cs" />
<Compile Remove="$(GeneratedPath)*.cs" />
<Compile Include="$(GeneratedPath)*.cs" />
</ItemGroup>
</Target>
</Project>
2 changes: 1 addition & 1 deletion interfaces/dotnet/Cantera/src/CanteraInfo.cs
Expand Up @@ -47,7 +47,7 @@ public void Add(DirectoryInfo dir)
_dirs.GetEnumerator();

public void AddAssemblyDirectory() =>
Add(Path.GetDirectoryName(GetType().Assembly.Location)!);
Add(Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location)!, "data"));
}

unsafe static readonly Lazy<string> _version =
Expand Down

0 comments on commit fbaa5d1

Please sign in to comment.