Skip to content

"exclude" doesn't work with new csproj format #3133

Description

@M0ns1gn0r

Description

I am converting one of my test projects to the new csproj format. The project references XUnit and an optional package XUnit.Assert.Source which adds source files of the assertion library to the project structure. I have to remove the transitive dependency Xunit.Assert which includes the compiled version of the same assertions so that no conflicts occur. This worked well for the traditional csproj.

Repro steps

paket.dependencies:

source https://www.nuget.org/api/v2
nuget xunit
nuget xunit.assert.source

paket.references

xunit
    exclude xunit.assert
xunit.assert.source

TestOfExclude.csproj

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Asserts\Assert.cs">
      <Paket>True</Paket>
    </Compile>
    .... and so on ....
    <Compile Include="Asserts\Sdk\Exceptions\XunitException.cs">
      <Paket>True</Paket>
    </Compile>
  </ItemGroup>
  <Import Project="..\.paket\Paket.Restore.targets" />
</Project>

A project with the reproduction TestOfExclude.zip

Expected behavior

  1. XUnit.Assert is not included in the list of referenced NuGet packages.
  2. The project compiles.

Actual behavior

The opposite, more than 200 errors like this:
CS0111 Type 'Assert' already defines a member called '.ctor' with the same parameter types TestOfExclude\Asserts\Assert.cs

Activity

  1. petrkoutnycz commented on Jan 28, 2020

    @petrkoutnycz

    I've tested this behavior with paket 5.241.6 and it does not seem to work. Having the same issue. Not saying that docs states that exclusion relates to dlls, not nugets. So what is the current state please?
    https://fsprojects.github.io/Paket/references-files.html

  2. luithefirst commented on Jan 26, 2021

    @luithefirst

    For me, the issue also does not look resolved. After porting a project to the new style SDK project format, excluded assemblies are copied to the output directory.

    When testing with "TestOfExclude.zip" and using paket.exe 5.257.0 it is also not working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions