-
Notifications
You must be signed in to change notification settings - Fork 389
When publishing test project "CopyCoverletDataCollectorFiles" overwrites project assemblies #1131
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
You're publishing tests project and test on different machine which what command(can you attach command line to understand your workflow). Is it .NET Framework right(not .NET Core)? |
Experiencing this as well. This is the command we're using: Coverlet is overwriting *.dll's of dependencies that it shares with "$csproj". For example, our "$csproj" has a dependency on |
I am having the same issue. The documentation states:
But when you publish a project that references coverlet.collector, all the contents of We are building and testing like this:
(i.e. we test existing assemblies using |
Workaround which worked for me: downgrade coverlet.collector to version 1.3.0 |
Hi all! Can someone dogfood this preview version with the fix attempt and tell me if it works? |
I am using version of coverlet.collector 3.1.2 for .NET 6 project (target framework -> net6.0) and locally and even on GitHub Actions it's not working. So every time problem with rewriting libraries:
It's really strange because on Windows build it's not working for publishing the web service. But in Docker build with Linux image application works as expected and starts from container without any issues. Packages installed for Test project: So i am not sure that this issue resolved or need to do something else, configure or tune the build and publish logic. Thanks. |
Hi all, I have an application targeting net 6.0. We are including coverlet.collector 3.1.2 as a package reference to our test projects. We are also experiencing problems during dotnet publish where Microsoft.Extensions.DependencyInjection.dll and Microsoft.Extensions.DependencyInjection.Abstractions.dll overwrite our desired versions of these assemblies. This thread implies that this was fixed as part of #1243 Looking at the PR, I see the addition to the targets file: As mentioned, out of the box, this is still clobbering these dependencies with older version that are within the nuget folder. Is there something else that needs to be done to stop this behavior from happening? Previous responses in this thread imply that it is fixed out of the box, so I would like some clarification. Where does ResolvedFileToPublish get defined? Is this something we need to add to our unit test csproj file: Ex:
Thank you! |
@Digiman , I too have this problem - were you able to resovle this? |
The fix was done for If you run the publish using the |
Hi @MarcoRossignoli , Yes, I am having this problem with publish. I have explicitly added Microsoft.Extensions.DependencyInjection.Abstractions.dll and Microsoft.Extensions.DependencyInjection.dll as package references to the project, and after running the dotnet publish command, the output directory contains the 2.2.0 version instead of the expected 6.0.0 version. Below is the sample command: `C:\Code\MyCompany\application>dotnet.exe publish C:\Code\MyCompany\application\MyCompany.MyModule.MyProduct.Azure.Tests /bl --configuration Release --no-build -o c:\temp\pub C:\Program Files\dotnet\sdk\6.0.300\MSBuild.dll -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\6.0.300\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\6.0.300\dotnet.dll -maxcpucount -property:PublishDir=c:\temp\pub -property:NoBuild=true -property:Configuration=Release -target:Publish -verbosity:m /bl C:\Code\MyCompany\application\MyCompany.MyModule.MyProduct.Azure.Tests\MyCompany.MyModule.MyProduct.Azure.Tests.csproj |
@osiwshaya are you able to check the msbuild with https://msbuildlog.com/ like #1243 (comment) to check why the files are not excluded from the publish? |
We have several test projects that we run "dotnet publish" to create an artifact to be run on a different machine from the build machine and when doing this we would get assembly binding errors like:
System.IO.FileLoadException : Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I found that when the project was built with dotnet build, it would have the correct version of System.Threading.Tasks.Extensions but when dotnet publish was run on the project, the System.Threading.Tasks.Extensions would be replaced with an older version (Version 4.0.0.0).
I traced this down to a build target here:
https://github.com/coverlet-coverage/coverlet/blob/bfaa38f761b0b8e88661e364e0a49c559021003b/src/coverlet.collector/build/netstandard1.0/coverlet.collector.targets
That copies all the assemblies in the build\netstandard1.0 directory to the publish directory. I'm not sure why this is done but many of the assemblies in this directory are assemblies that the project itself might also have and this copy ends up resulting in older assemblies being copied into the directory and autogeneratebindingredirects will have created binding redirects for the original assemblies and thus the tests will fail when trying to load these assemblies.
The text was updated successfully, but these errors were encountered: