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

Powershell with /p:ExcludeByFile do not works #122

Closed
default-writer opened this issue Jun 18, 2018 · 10 comments · Fixed by #524
Closed

Powershell with /p:ExcludeByFile do not works #122

default-writer opened this issue Jun 18, 2018 · 10 comments · Fixed by #524
Labels
bug Something isn't working

Comments

@default-writer
Copy link

default-writer commented Jun 18, 2018

Powershell script
By adding command /p:ExcludeByFile=\"**/MyFun*.cs,**/*Test*.cs,**/*Exception*.cs,**/*Attribute*.cs\" to

& dotnet test --configuration Release --no-build Build.Tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

I manage to break generation of the report file, if I removes /p:ExcludeByFile=\"...\" everything works
I tried with no success:


/p:ExcludeByFile=\"**/MyFun*.cs,**/*Test*.cs,**/*Exception*.cs,**/*Attribute*.cs\"
/p:ExcludeByFile="**/MyFun*.cs,**/*Test*.cs,**/*Exception*.cs,**/*Attribute*.cs"
/p:ExcludeByFile=\"**\/MyFun*.cs,**\/*Test*.cs,**\/*Exception*.cs,**\/*Attribute*.cs\"
/p:ExcludeByFile=\"**\MyFun*.cs,**\*Test*.cs,**\*Exception*.cs,**\*Attribute*.cs\"
/p:ExcludeByFile="**\MyFun*.cs,**\*Test*.cs,**\*Exception*.cs,**\*Attribute*.cs"

/p:ExcludeByFile just not works

https://ci.appveyor.com/project/hack2root/build/build/1.0.0.222-master
https://ci.appveyor.com/project/hack2root/build/build/1.0.0.223-master

Why not to use SonarScanner format

/d:sonar.coverage.exclusions="**/MyFun*.cs,**/*Test*.cs,**/*Exception*.cs,**/*Attribute*.cs"

for /p:ExcludeByFile, for example:

/p:ExcludeByFile="**/MyFun*.cs,**/*Test*.cs,**/*Exception*.cs,**/*Attribute*.cs"

My build script:

& packages/dotnet-sonarscanner begin /d:sonar.login="$env:SONARCLOUDTOKEN" /k:"build-core" /d:sonar.host.url="https://sonarcloud.io" /n:"build" /v:"1.0" /d:sonar.cs.opencover.reportsPaths="Build.Tests/coverage.opencover.xml" /d:sonar.coverage.exclusions="**/MyFun*.cs,**/*Test*.cs,**/*Exception*.cs,**/*Attribute*.cs" /d:sonar.organization="hack2root-github" /d:sonar.sourceEncoding="UTF-8"
& dotnet build --configuration Release
& dotnet test --configuration Release --no-build Build.Tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
& packages/dotnet-sonarscanner end /d:sonar.login="$env:SONARCLOUDTOKEN"
& packages/csmacnz.Coveralls --opencover -i Build.Tests/coverage.opencover.xml
@default-writer default-writer changed the title Powershell with /p:ExcludeByFile Powershell with /p:ExcludeByFile do not works Jun 18, 2018
@tonerdo
Copy link
Collaborator

tonerdo commented Jun 19, 2018

I'd expect this to just work since you're using a regular globbing pattern. @ido-namely can you please take a look? Thanks

@tonerdo
Copy link
Collaborator

tonerdo commented Sep 1, 2018

Hi @hack2root, do you get an error or does it just not work? Is your issue similar to #182?

@SlowLogicBoy
Copy link
Contributor

SlowLogicBoy commented Sep 5, 2018

I'm having same issue. Also I use test.targets file for test properties:

    <PropertyGroup>
        <!-- Properties for code coverage -->
        <CollectCoverage>true</CollectCoverage>
        <CoverletOutputFormat>opencover</CoverletOutputFormat>
        <ExcludeByFile>**/*.Designer.cs,**/*.g.cs,**/*.g.i.cs,**/*.generated.cs</ExcludeByFile>
    </PropertyGroup>

and this doesn't work too. I've tried solutions in #182 too, in powershell, cmd and bash. (in bash instead of using /p: I have to use -p:)

@tonerdo
Copy link
Collaborator

tonerdo commented Sep 7, 2018

@SlowLogicBoy I'll like to know if you get an error or if you just notice that the files don't get excluded

@SlowLogicBoy
Copy link
Contributor

SlowLogicBoy commented Sep 10, 2018

@tonerdo Files didn't get excluded, tried various patterns for these. Exclude doesn't work also.

@orkenstein
Copy link

/p:ExcludeByFile definitely doesn't work in shell.

@psfinaki
Copy link

So what am I supposed to do if I want to exclude some Migrations folder?

Something like
dotnet test Code /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Exclude="**/Migrations/**"

@yowl
Copy link

yowl commented Apr 24, 2019

I'm a bit confused with the state of this. Does this also affect coverlet.exe and is the workaround to use absolute paths?

@yowl
Copy link

yowl commented Apr 24, 2019

I aslo note I think, that with absolute paths on windows its funny about the case of the drive letter and I need to exclude both d:\ and D:\

@stanislav-trifan
Copy link

still not working on .net 3.1.411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants