Skip to content

[Tests] Local Testing of single Mapster Projects fails for SolutionDir is not always set when building a project directly via dotnet test #848

@DevTKSS

Description

@DevTKSS

I was locally trying around with the DI Package to look into my suggested Idea to enable something like MapsterOptions from appsettings.json.

But testing via dotnet test path/to/csproj fails on the Directory.Build.props file uses SolutionDir which is not or not always set, which causes that Copilot constantly edits the Directory.Build.props with this:

<!--
	SolutionDir is not always set when building a project directly (e.g. `dotnet test path/to/csproj`).
	Fall back to the key path relative to this props file (src/Mapster/Mapster.snk).
-->
<AssemblyOriginatorKeyFile Condition="Exists('$(SolutionDir)Mapster\\Mapster.snk')">$(SolutionDir)Mapster\Mapster.snk</AssemblyOriginatorKeyFile>
		<AssemblyOriginatorKeyFile Condition=" '$(AssemblyOriginatorKeyFile)' == '' and Exists('$(MSBuildThisFileDirectory)Mapster\\Mapster.snk')">$(MSBuildThisFileDirectory)Mapster\Mapster.snk</AssemblyOriginatorKeyFile>

Which includes in the .csproj the marked lines:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net10.0;net9.0;net8.0;</TargetFrameworks>
    <Description>Dependency Injection supports for Mapster</Description>
    <IsPackable>true</IsPackable>
    <PackageTags>Mapster;DependencyInjection</PackageTags>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>Mapster.DependencyInjection.snk</AssemblyOriginatorKeyFile>
    <Version>10.0.0-pre01</Version>
  </PropertyGroup>

Since I so far never worked with Signing Assemblys or similar, I don't know for what build/release step we are exactly needing this, assuming just for the Package Creation - Release step, isnt it?

I am quite sure @andrerav or you others @DocSvartz @stagep might have some information and solution? 😁

How do you do this when you others are testing locally?
Is there some kind of trick, except from always building the solution? 😓
Could we have this fixed possibly?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions