Skip to content
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

use a custom MSBuild task #971

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

use a custom MSBuild task #971

wants to merge 2 commits into from

Conversation

adamralph
Copy link
Owner

closes #112

Co-authored-by: Brandon Ording <bording@gmail.com>
@adamralph adamralph changed the title Switch net6.0 task use a custom MSBuild task Jan 17, 2024
@adamralph
Copy link
Owner Author

MinVer/MinVer.csproj Outdated Show resolved Hide resolved
MinVer/MinVer.csproj Outdated Show resolved Hide resolved
@@ -4,8 +4,12 @@
<MSBuildAllProjects Condition="'$(MSBuildAssemblyVersion)' == '' Or '$(MSBuildAssemblyVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);MinVer</GenerateNuspecDependsOn>
<GetPackageVersionDependsOn>$(GetPackageVersionDependsOn);MinVer</GetPackageVersionDependsOn>
<MinVerTaskPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\minver\net6.0\MinVer.dll</MinVerTaskPath>
<MinVerTaskPath Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\minver\net472\MinVer.dll</MinVerTaskPath>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bording this doesn't seem right. The MinVer project isn't targetting net472.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MinVer project isn't targetting net472.

It will need to. I didn't bother with changing that in my spike, but you'll need to multi-target and build a net472 version of the task assembly as well to support .NET Framework MSBuild, which is used by Visual Studio.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh... that's a pain. Does even the latest version of VS use .NET Framework MSBuild?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... what concerns me about this is that the net472 code path will be untested in CI. Local smoke testing would be one option to mitigate that but it's not easy for me to do so since I no longer use Windows. I guess it's unlikely that the net472 version will have problems if the net6 version doesn't but it's the edge cases/unknown unknowns that I'm wary of. I have to say this gives me cold feet about switching to an MSBuild task.

Is the caching part of your spike only possible if we switch to an MSBuild task?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... what concerns me about this is that the net472 code path will be untested in CI

That doesn't have to be true, though. It would certainly be possible to have tests that also verify behavior on net472.

I have to say this gives me cold feet about switching to an MSBuild task.

I don't really understand this, and given the benefits of doing it, I really don't agree.

Is the caching part of your spike only possible if we switch to an MSBuild task?

Yes, it's relying on APIs that only accessible from a task.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't have to be true, though. It would certainly be possible to have tests that also verify behavior on net472.

I guess it is possible, but it would not require running tests conditionally, on Windows only, calling msbuild.exe?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what sort of tests you're thinking of. Most of the logic would just be testable directly, and the test projects could be multi-targeted, so that would take care of that.

If you want some sort of integration test, then that would need to use dotnet/msbuild.exe and to use the respective task assemblies, but that also seems rather doable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use a custom MSBuild task
2 participants