New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency on Microsoft.Build.Utilities #2129
Conversation
@arturcic - this may sound stupid, but how do I find the nuget package for this PR so I can give it a try? Do PR nuget packages get published anywhere? |
I think you can use appveyor's feed |
Co-Authored-By: Joseph Petersen <josephp90@gmail.com>
- It was broken, and hard to debug due to static initialisers that can't set a break point in. - .MsBuild project -> netstandard. This was attempted before but due to cross compilation it would have caused issues, has to move platform specific code into GitVersionTask.
@arturcic |
…Version into task-msbuild-fixes
https://github.com/GitTools/GitVersion/blob/master/src/GitVersionTask/nuget-files.props, This is the file that specifies how the nuget file is generated. It is created when calling dotnet pack from cake |
I think we can release the new version without this issue, and work on this on the next version. @dazinator thoughts? |
The net472 is broken, what about the netcore? |
We are testing in containers the netcore version of the task and it seems to be working |
Yeah dotnet build works and I saw the checks for that. It was just msbuild I was hitting issues with - which is equivalent to building a project from VS. |
msbuild with .netcore or with net472? |
Net472 |
Ok I'll think about |
I saw some existing logic for example when resolving dependencies from the 472 folder, it only resolves System.* - so where we have added a dependency to Micorsoft.Extensions.DependencyInjection that was causing an exception for me. I should have pushed up a specific fix for that but instead I went on a bit or anrefacoting exercise in my PR as a lot of the initialisation logic was in a static constructor where I couldnt hit any break points. All this is me testing on my local environment though, so I am hesitant to say anything I have discovered is absolutely conclusive until we also catch it with a check / test on a build server. |
So the first think we should do is to have tests for msbuild in containers similar to the dotnet build to catch the issue, then to fix the issue, right? |
Yeah that would be really good. Maybe starting with whatever the current stable msbuild version is. Then we can always add other versions tied to particular VS versions we want to support after that. A stretch goal would be to also run a check where it dynamically installs the latest preview version of msbuild corresponding to the current VS preview release channel, and tests using that (that would allow us to discover if GitVersionTask will not work with the latest release of msbuild rolled out to VS preview users - and potentially do something about it like update documentation or create a fix etc). Probably a bit optimistic on my part there. |
Note to self: When MSBuild loads the Task on .NET Core, it loads the type into its own AssemblyLoadContext, over which we don't have any control in terms of resolving dependencies as they are needed. Because of this, we can't place any logic that would cause a dependency to load in the typical Task.Execute() method that MSBuild calls, because that will fail when MSBuild is unable to resolve those dependencies from its own AssemblyLoadContext. So the approach I refactored to in this PR doesn't currently work for .NET Core because I attempt to load the same task Type from our own AssemblyLoadContext, then create an instance of it, and then Invoke a method on it: OnProxyExecute() - the idea being the task can then still encapsulate its own logic on the OnProxyExecute() method instead of OnExecute(). I had forgot about this issue of trying to use the same type from two different LoadContexts, and that is why tests in my PR currently fail after my refactoring. I need to change it back to along the lines of leveraging the pattern we had prior to my PR:
Knowing this I'll try to fix up the failing tests. Note: interestingly, this issue doesn't exist under full .NET, as in that case we can handle how msbuild resolves assemblies, using AssemblyResolve events for the current app domain. Therefore when a task is executed, as long as our AssemblyResolve ebent handlers are in place, we can execute task logic as normal at that point. However I imagine we want the execution pipeline for tasks to look consistent irrespective of Platform. |
I could not explain better the current implementation. |
@arturcic I think I'll add a README or something to the GitVersionTask project - I knew this about 8 months ago but had forgotten :-( |
works for me |
Abandoning this, in favour of a new one. |
Remove unnecessary dependencies on Microsoft.Build.* packages in an effort to help alleviate GitVersionTask errors when running from with VS, some of which described here: #2125