Skip to content

Conversation

@github-actions
Copy link
Contributor

Backport f08b6b7 from #4581

This commit fixes the inclusion of InternalsVisibleToAttributes for
versioned assemblies.

Directory.Build.Targets defines an AssemblyInfos target that
writes InternalsVisibleTo elements for friend assemblies and
versioned friend assemblies, based on the InternalsVisibleTo
elements in the target csproj and the version being built. This worked
fine when built from Rider IDE (and likely Visual Studio too) due to
the way in which MsBuild is invoked from IDE, but did not work as intended
when built from the commandline with the build script, which calls
dotnet build; The Nest InternalsVisibleTo was correctly written, but
none of the InternalsVisibleTo for generated Elasticsearch.Net assemblies
were. Looking at the binarylog for MsBuild with the Structured Log Viewer
indicated that the task was working as expected from the command line and
\obj\$(Configuration\AssemblyInfo.cs generated file was written correctly,
but inspection of the file revealed that the InternalsVisibleTo attributes
were in fact not generated correctly.

In researching friend assemblies, https://docs.microsoft.com/en-us/dotnet/standard/assembly/friend
notes the following

> When you compile an assembly like AssemblyB that will access internal types or
internal members of another assembly like Assembly A, you must explicitly specify
the name of the output file (.exe or .dll) by using the -out compiler option.
This is required because the compiler has not yet generated the name for the assembly
it is building at the time it is binding to external references.

The build script does not pass an output path, relying on the convention of
output going to /bin/$(Configuration)/$(TargetFramework)/. When the IDE
builds projects, it explicitly passes an output path. In summary, the fix to
allow InternalsVisibleTo to work as expected from the commandline is to explicitly
pass an output path. This is done for all projects by adding

<OutDir>bin/$(Configuration)/$(TargetFramework)/</OutDir>

to Directory.Build.Targets.

Fixes #4538
@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@russcam russcam merged commit 096700a into 7.7 Apr 15, 2020
@russcam russcam deleted the backport-4581-to-7.7 branch April 15, 2020 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants