Refactor packaging and remove Fody.nuspec.#1312
Conversation
|
|
||
| <ItemGroup Condition="$(TargetFramework) == 'netstandard2.0'"> | ||
| <PackageReference Include="System.Runtime.Loader" Version="4.3.0" /> | ||
| <PackageReference Include="System.Runtime.Loader" Version="4.3.0" ExcludeAssets="Runtime" /> |
There was a problem hiding this comment.
This makes System.Runtime.Loader.dll to not get included. It wasn't included before and it wasn't causing any problem.
|
I'm not sure why AzDo fails. 🤔 |
Seems to be a server problem, after re-starting they all ran successful |
| @@ -0,0 +1,16 @@ | |||
| <Project> | |||
There was a problem hiding this comment.
What is the benefit from putting this into a global scope, and then only enabling for one single project?
There was a problem hiding this comment.
It is enabled for both Fody and FodyHelpers.
|
@ltrzesniewski the I've been making the packages on my machine with |
|
Hmm, that's linked to NuGet/NuGet.Client#2822 and NuGet/Home#7801 which is supposed to be fixed... I think I'll play with the changes in this PR a bit and try to simplify them. Do we even want to keep |
|
With my latest commits, the list of files in |
| <None Include="Fody.targets" Pack="true" PackagePath="build" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- ExcludeAssets="compile" doesn't work on ProjectReference, and ReferenceOutputAssembly entirely |
There was a problem hiding this comment.
That's so much hacking with compiler internals. Wouldn't it be much clearer and easier to understand what's going on when we use `ReferenceOutputAssembly=false and then just copy the files manually?
There was a problem hiding this comment.
e.g. like this:
<Target Name="CopyFodyIsolatedToOutput" AfterTargets="CopyFilesToOutputDirectory">
<ItemGroup>
<_FodyIsolatedFile Include="..\FodyIsolated\bin\$(Configuration)\$(TargetFramework)\*.*" />
</ItemGroup>
<Copy SourceFiles="@(_FodyIsolatedFile)" DestinationFolder="$(OutputPath)" />
</Target>There was a problem hiding this comment.
My proposed solution does precisely what we want to achieve (remove FodyIsolated from the references we pass to the compiler), and I believe it is less fragile and more maintainable down the road.
Manually copying the output of FodyIsolated assumes that it gets written to a specific location (which could change in the future), and that the project targets the same frameworks as Fody. My proposed solution makes none of these assumptions. Hardcoding output paths also brings back what we were doing in the .nuspec file, the removal of which is the objective of this PR.
I will file a feature request to MSBuild to make this scenario easier (a CopyLocalOutputAssembly metadata on ProjectReference).
|
What about moving the NuGet generation to a separate project? This would make all the workarounds obsolete: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
<BuildOutputTargetFolder>tasks</BuildOutputTargetFolder>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<PackageId>Fody</PackageId>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\FodyIsolated\FodyIsolated.csproj" />
<ProjectReference Include="..\Fody\Fody.csproj" />
</ItemGroup>
</Project> |
|
I thought about it, but didn't have time to try it yet. I have used this approach in a few projects of mine and it works well. BTW I'd put |
Really? Which ones? |
|
I see, I never ran |
|
Oh, and here are examples of how I use a separate project to produce a package:
|
|
The above sample does exactly what we need in terms of binaries, just metadata and Fody.targets need to be added. |
|
I haven't tried it yet, but doesn't that |
|
Yes, there is a warning during restore, that project needs to be renamed. |
|
It's only a POC that this is sufficient to output the binaries as we need them |
|
I like it if it gets rid of the more complex stuff. Do you intend to work on it a bit more and push it to this PR? |
|
@teo-tsirpanis what do you think? Maybe you can do an adaption, since I probably could continue earliest next weekend. |
|
I took a first stab at this and created a separate @tom-englert, feel free to push on my branch whenever you have time, thanks. Also the approach used by RazorBlade and ZeroLog is IMHO an overkill. These are "simple" packages that do not bundle their dependencies and have just an analyzer and some MSBuild files added on top, and the extra packaging project causes the library to be compiled twice as many times. |
Yes, I'm aware. Both of these libraries have good reasons to be set up like that, and they're not as simple as they look like at first glance. The multiple compilation is not an issue at all (both of these projects even have some files be compiled 3 times). Of course, I wouldn't use this approach for more standard libraries though. |
|
Superseded by #1313 |


You should already be a Patron
I am!
Description
The
Fodypackage is currently being created with a.nuspecfile which explicitly specifies the locations of every file in the package. This is not ideal because it relies in the exact output paths of the library and its dependencies, and also relies on the solution file to enforce a build order for some projects.The solution
This PR removes
Fody.nuspecand uses MSBuild facilities to define the structure of theFodypackage. Some of the techniques used are described here.Validated by manually inspecting that the files in the
Fodypackage built from this branch are the same, with the following exceptions:netclassictaskandnetstandardtasktotasks/net472andtasks/netstandard2.0for .NET Framework and .NET Standard respectively.Next to the .NET Standard 2.0 task assembly there is a.deps.jsonfile. This helps MSBuild resolve the task's dependencies.FodyHelpers.xmlwas included in the package (I can remove it if I try more).Todos