Skip to content

Commit

Permalink
Linux builds and assembly attributes cleanup (#258)
Browse files Browse the repository at this point in the history
* Move assembly parameters to Directory.Build.props, closes #257
* Fix GetAssemblyCodeBasePath() for Linux deployments, closes #250
  • Loading branch information
cd21h committed Oct 25, 2021
1 parent 6a67d03 commit b90d11f
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 75 deletions.
21 changes: 19 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
<PropertyGroup Label="Build">
<Product>Sharp Architecture</Product>
<Authors>Sharp Architecture Dev Team</Authors>

<Copyright>Copyright &#xA9; Sharp Architecture Development Team</Copyright>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<Culture></Culture>
<SignAssembly>false</SignAssembly>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
Expand Down Expand Up @@ -59,6 +62,13 @@
<NoWarn>$(NoWarn);0618;1591</NoWarn>
</PropertyGroup>

<ItemGroup Condition="'$(MSBuildProjectName.Contains(Tests))' == false">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>SharpArch.XunitTests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>


<PropertyGroup Condition="'$(MSBuildProjectFullPath.Contains(Sample))' == true">
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);1591</NoWarn>
Expand All @@ -73,4 +83,11 @@
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.InteropServices.ComVisibleAttribute">
<_Parameter1>false</_Parameter1>
<_Parameter1_TypeName>System.Boolean</_Parameter1_TypeName>
</AssemblyAttribute>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>

<ItemGroup Label="Package References (.NET 5)" Condition=" '$(TargetFramework)' == 'net5' ">
<ItemGroup Label="Package References (.NET 5)" Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

Expand Down
13 changes: 0 additions & 13 deletions Src/Common/CommonAssemblyInfo.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Src/SharpArch.Domain/Properties/AssemblyInfo.cs

This file was deleted.

1 change: 0 additions & 1 deletion Src/SharpArch.Domain/SharpArch.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
</ItemGroup>

<PropertyGroup Label="Pack">
Expand Down
7 changes: 5 additions & 2 deletions Src/SharpArch.Infrastructure/CodeBaseLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ public class CodeBaseLocator
public static string GetAssemblyCodeBasePath(Assembly assembly)
{
if (assembly == null) throw new ArgumentNullException(nameof(assembly));

#if NET5_0_OR_GREATER
var uri = new UriBuilder(assembly.Location);
return Path.GetDirectoryName(assembly.Location)
?? Directory.GetCurrentDirectory();

#else
var uri = new UriBuilder(assembly.CodeBase);
#endif
var uriPath = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(uriPath)!;
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
</ItemGroup>

<ItemGroup Label="NETStandard 2.0" Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
</ItemGroup>

<PropertyGroup Label="Pack">
Expand Down
2 changes: 1 addition & 1 deletion Src/SharpArch.NHibernate/EntityDuplicateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[PublicAPI]
public class EntityDuplicateChecker : IEntityDuplicateChecker
{
static readonly DateTime _uninitializedDatetime;
static readonly DateTime _uninitializedDatetime = default;
readonly ISession _session;

/// <summary>
Expand Down
16 changes: 0 additions & 16 deletions Src/SharpArch.NHibernate/Properties/AssemblyInfo.cs

This file was deleted.

1 change: 0 additions & 1 deletion Src/SharpArch.NHibernate/SharpArch.NHibernate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
</ItemGroup>

<PropertyGroup Label="Pack">
Expand Down
10 changes: 0 additions & 10 deletions Src/SharpArch.RavenDb/Properties/AssemblyInfo.cs

This file was deleted.

1 change: 0 additions & 1 deletion Src/SharpArch.RavenDb/SharpArch.RavenDb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
</ItemGroup>

<PropertyGroup Label="Pack">
Expand Down
7 changes: 0 additions & 7 deletions Src/SharpArch.Testing.NUnit/Properties/AssemblyInfo.cs

This file was deleted.

1 change: 0 additions & 1 deletion Src/SharpArch.Testing.NUnit/SharpArch.Testing.NUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
<Compile Include="..\Common\NHibernate\TestDatabaseSetup.cs" Link="NHibernate\TestDatabaseSetup.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
<Compile Include="..\Common\NHibernate\TestDatabaseSetup.cs" Link="TestDatabaseSetup.cs" />
</ItemGroup>

Expand Down
1 change: 0 additions & 1 deletion Src/SharpArch.Testing.Xunit/SharpArch.Testing.Xunit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
</ItemGroup>

<PropertyGroup Label="Pack">
Expand Down
1 change: 0 additions & 1 deletion Src/SharpArch.Testing/SharpArch.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
</ItemGroup>

<PropertyGroup Label="Pack">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ItemGroup>
<Compile Include="..\Common\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\Common\CommonAssemblyInfo.cs" Link="CommonAssemblyInfo.cs" />
</ItemGroup>

<PropertyGroup Label="Build">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Tests.SharpArch.Infrastructure
{
using System;
using System.IO;
using System.Reflection;
using FluentAssertions;
using global::SharpArch.Infrastructure;
using Xunit;
using Xunit.Abstractions;


public class CodeBaseLocatorTests
{
readonly ITestOutputHelper _output;

public CodeBaseLocatorTests(ITestOutputHelper output)
{
_output = output ?? throw new ArgumentNullException(nameof(output));
}

[Fact]
public void CanResolveAssemblyPath()
{
var path = CodeBaseLocator.GetAssemblyCodeBasePath(Assembly.GetExecutingAssembly());
_output.WriteLine("Assembly path: '{0}'", path);
path.Should().NotBeNullOrEmpty();
Directory.Exists(path).Should().BeTrue();
}
}
}
4 changes: 4 additions & 0 deletions Src/Tests/SharpArch.XunitTests/SharpArch.XunitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@
<ProjectReference Include="..\..\SharpArch.Testing\SharpArch.Testing.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="SharpArch.Infrastructure\" />
</ItemGroup>

</Project>

0 comments on commit b90d11f

Please sign in to comment.