dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.17k stars 1.34k forks source link

Distribute the MSBuild internal test helpers as a nuget package #3569

Open MeikTranel opened 5 years ago

MeikTranel commented 5 years ago

Some of the APIs such as "TestEnvironment", the custom loggers and assertion wrappers could be really helpful for people who distribute Custom MSBuild Tasks / Sdks.

jeffkl commented 5 years ago

I have created https://github.com/jeffkl/MSBuildProjectCreator as a test helper and its used in the MSBuildSdks repo:

https://github.com/Microsoft/MSBuildSdks/blob/master/src/CentralPackageVersions.UnitTests/CentralPackageVersionsTests.cs#L80

It does not do everything you mention but it does cover some of it.

MeikTranel commented 5 years ago

@jeffkl that does indeed help for some tasks and is definitely a good fit for a smaller projects who struggle with the most basic testing "infrastructure".

But at my workplace we're planning on investing in Custom SDKs and Task Packages on a much larger scale, where an official testing package build alongside the package we're testing would help greatly.

It's kind of an odd feature to have, but i have grown much more fond with the underlying idea since https://github.com/cake-build/cake 's test package. They serve the same basic need really. The application model is so odd/complex, that regular testing workflows and tooling is kinda all over the place for them.

The question to me would be: How much of an additional workload would it be for the product ownership of MSBuild to put this into the hands of some of the consumers. I'm sure the implementation of deployment wouldn't be an issue. Would you expect users of this package to use the package in a way that would drive the already implemented testing framework into places that it wouldn't naturally be (aka requiring APIs that serve no use the actual msbuild tests etc.)

baronfel commented 1 year ago

Would be lovely to do this - I replicated the helpers in https://github.com/dotnet/sdk/pull/26729 out of a desire to easily assert on logged messages.

MeikTranel commented 1 year ago

Hey @baronfel can you do some internal advertising for this to get some PM eyeballs on this?

Maybe we should wrap this in a larger vision and create an official MSBuild task package template - there seems to be much confusion about the entire system - which is why many people still use AfterBuild shell scripts seemingly confused that there even is something like a task that can act in a sane manner from within msbuild.

This discussion really shows this whole dilemma: https://github.com/dotnet/roslyn/issues/57608

Oh wait... you're PM :D:D