Commit 096700a
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
Co-authored-by: Russ Cam <russ.cam@elastic.co>
1 parent 033349e commit 096700a
File tree
3 files changed
+3
-5
lines changed- build/scripts
3 files changed
+3
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
168 | | - | |
169 | 167 | | |
170 | 168 | | |
171 | 169 | | |
| |||
0 commit comments