dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.02k stars 4.03k forks source link

Consider having CopyRefAssembly inherit from Copy #19103

Open rainersigwald opened 7 years ago

rainersigwald commented 7 years ago

The new CopyRefAssembly task has logic to determine whether a reference assembly is logically identical by comparing MVIDs of the source and destination files. If the MVIDs do not match, it copies the source assembly to the destination path.

As currently implemented, this copy doesn't have all of the bells and whistles of the Copy task, which supports retries and special-cases a number of scenarios.

CopyRefAssembly could inherit from Copy, override Execute(), do its up-to-date checks, and then after deciding to copy, forward to base.Execute() to get all of the additional magic.

This came up when discussing https://github.com/Microsoft/msbuild/issues/1986 with @jeffkl.

@jcouv -- something to think about. Doesn't block the initial implementation, since no MSBuild change would be required to pick this up.

jcouv commented 7 years ago

@rainersigwald I probably won't be able to do this in dev15.3 timeframe. I'll move to following milestone. Let me know if that causes pain.

rainersigwald commented 7 years ago

That should be fine. While making an unrelated change, I realized there is one wrinkle: you'll also need to continue to provide the DestinationPath output (in Copy it's named DestinationFiles). But that is easy.

jcouv commented 7 years ago

Along with this change, it would probably be good to find a way to unittest this Task in the Roslyn repo (it will make it easier to review/accept the PR).

My testing strategy so far was manual, following these steps and then trying various scenarios:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="CopyRefAssembly" AssemblyFile="D:\repos\roslyn\Binaries\Debug\Dlls\MSBuildTask\Microsoft.Build.Tasks.CodeAnalysis.dll"/>
  <Target Name="MyTarget">
      <CopyRefAssembly SourcePath="..." DestinationPath="..."/>
  </Target>
</Project>