-
Notifications
You must be signed in to change notification settings - Fork 651
[Bug] Build with GitVersion.MsBuild fails because GitVersionFileExe is not set #2502
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
Comments
Unfortunately the docs are not up to date. There are different areas in the docs that have to be updated. I'll add an issue for that
Wouldn't it be easier if you just add an additional condition for the
that will also handle the netstandard? |
My library targets |
Do you mind spending some time for a PR? so that we can review and eventually merge to fix it? |
When I encountered this (to add Mono MSBuild support) I ultimately thought this shouldn't check the Other tooling that integrates with MSBuild seems to ship with net46 and netstandard1.6 dlls and implements the whole logic inside that (i.e. the MSBuild tasks are inside those dlls and that is all the logic they run). So they neither invoke an .exe, nor do they invoke Any thoughts on this? It feels a bit involved for this library to maintain a list of all possible |
I would provide you with a PR, but I don't know the proper way to fix the issue. Currently GitVersion.Msbuild.props sets |
@bddckr sounds reasonable. However, I wouldn't go for netstandard1.6 anymore but netstandard2.0, which is supported by Full Framework since 4.7.2. |
Yeah that makes sense. I was thinking of supporting older MSBuild usages and I don't seem to be able to find what versions it supports (or requires), but I guess assuming the build machine has at least a .NET Standard 2.0 compatible framework installation is OK. |
That was the old way this package was working (when it was GitVersionTask). But we had quite a lot of issues because GitVersion relies on Libgit2Sharp with native libs embedded. There are some limitations on how the native libs are loaded by msbuild, you needed to provide a custom AssemblyLoader that needs to implement the resolving of the native dependencies depending on the RID. And in order to support all the platforms you have to update the RID manually and so on. So plenty of issues we had in the past. Then we switched to this This way we let the executable resolve its dependencies the usual way and we just consume its ouptut |
Ha, I should have found that post instead!
I see. Definitely makes a lot of sense to me. I really like @thoemmi's suggestion on resolving this with a catch-all fallback. So to summarize I wonder if this would work:
Is there a need to ship a net5.0 dll and run that? Isn't the .NET 5 SDK/runtime backwards compatible with previous .NET Core assemblies? If that's the case the above simplification should work and there is no need to check for .NET 5 vs. .NET Core 3.1 etc. I.e. ship net48 and netcoreapp3.1 dlls only. |
Actually there are differences. I've tried embedding only 3.1 bits and use it on .net5.0 but the exe was asking for net50 runtime Then I tried the vice-versa, to embed 5.0 bits then it was asking for netcore 3.1 runtime. Also the dlls for the tasks on each runtime have different set of dependencies in the publish output so they cannot be used by both targets. |
I can see the same issue |
Similar error on Ubuntu 18.04 trying to build for
Same problem trying to load the project in Rider. |
Interesting. It runs and builds in Visual Studio without a problem. Haven't tried VS code though. |
In that case maybe it makes sense to have the fallback solution @thoemmi initially suggested, but instead of
we use
|
In my case, I have changed all TargetFrameworks to |
The problem in my case is that |
I guess, that's what the error is trying to tell us: |
Sorry to disturb you again, but is there a quick fix workaround that might work on a build server (Gitlab CI) with the environment described already in issue #2465? Right now, I'm building manually on my local computer which is ok, but sucks for a long term perspective. |
I believe #2518 is forcing us to ensure we don't switch the used task dlls in a solution. I.e. switching by target framework of a specific project breaks builds for anyone who has projects with different target frameworks in the same solution, while all the affected projects use GitVersion.MsBuild. |
My latest suggestion is to ask users to have (the runtime of) .NET 5.x installed as a requirement for using GitVersion.MsBuild. With that required we can now only ship the net5.0 dlls, both for the MSBuild tasks to load from them, but also for the dll to execute with That would reduce the maintenance burden to a single target framework for this library. Users only need the runtime for their dev environment, and since .NET is happy to be installed side-by-side with any other version that should be fine. Alternatively we could only aim for .NET Core 3.1 for now of course, but I think it's in the interest of the maintainers of this library to stay with the latest and greatest if possible. There doesn't seem to be a downside for consumers besides having to install the .NET 5 SDK (or runtime only), which they probably have anyway (especially when they use the latest Visual Studio versions with the .NET component installed). |
This would make things a lot easier for the maintainers of the project, I guess. |
@thoemmi, @bddckr, @SeppPenner, @ermshiperete do you mind to check the #2521 solution if it solves the issue? If you can confirm I will merge it |
It works for me on my dev machine :) |
Is it working for net5.0-windows as well? |
That works for me on the following machines/projects:
I've confirmed it builds the listed projects on both machines from both inside Visual Studio, but also from the CLI. The only thing I'm unable to test with my solution is I've run each test at least 3 times on a cleared cache, but also as an incremental build. Each time I made sure I'm building a bunch of projects concurrently, too (as that triggered the issue for me most of the time). Previously this would have hit the bug in each run, but I'm unable to reproduce now 👍 |
I have tested on Windows 10 with Visual Studio 2019 and one I sadly can't test for Linux or macOs...
I did several rebuilds and cleans, too. |
I can confirm that this works with our build server, too :) (With the Debian Buster Docker base image). 👍 |
Because GitVersionTask seems to be deprecated, I have switched to the GitVersion.MsBuild package. However, the build of my netstandard2.1 library fails with the message
I have noticed that in
GitVersion.MsBuild.props
,GitVersionFileExe
andGitVersionAssemblyFile
are not set when the target framework is netstandard2.1. SeeGitVersion/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props
Lines 19 to 32 in 69431b4
I've fixed it on my local machine by adding following fallback:
I have created a repo to reproduce the issue at https://github.com/thoemmi/GitVersionMsBuildIssue
This fixed the build. However, on every build a gitversion.json file is generated in each project folder, which is really annoying. Is there another MsBuild property required to supress that?
Regarding the deprecation of GitVersionTask: The documentation for MSBuild Task still mentions the GitVersionTask package.
The text was updated successfully, but these errors were encountered: