Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to remove .ncrunchproject files from .Net Core project
IlyaC
#1 Posted : Thursday, February 21, 2019 8:14:41 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 7
Location: Norway

I have added NCrunch to my .Net Core solution and now this file was added to all projects:

ProjectName.v3.ncrunchproject
I have added this to gitignore so it's not going to source control, but how can I remove it from Project?

There is an option of excluding this file explicitly in each and every project by either clicking Exclude in menu or adding it manually in .csproj file. I hope though that a better solution exists.

Maybe it's possible to tell ncrunch to store files some other place perhaps?
Remco
#2 Posted : Thursday, February 21, 2019 10:43:52 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,974

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
Hi, thanks for posting.

The .NET Core CPS project system used by VS will implicitly include any file in the project directory. It isn't safe for NCrunch to mess with this logic.

You can, however, configure NCrunch to place its config files in a different place using the project config file storage path configuration setting.
IlyaC
#3 Posted : Thursday, February 28, 2019 9:00:30 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 7
Location: Norway

Thanks for the answer, I agree it's not smart to mess with .net core logic, but if it's possible to move files it's good enough.
The solution worked just fine, though there is still solution level ncrunch files, but they are not a problem since they can just be gitignored and are not included in projects.

Since that seems like something that everyone will want to have for every .net core solution, maybe it makes sense to have it by default with e.g. "_NCrunch_ProjectFiles" or something like that alongside "_NCrunch_SolutionName"? It's not too complicated to do it for every solution, but is there any drawback by having NCrunch do it by default?
GreenMoose
#4 Posted : Thursday, February 28, 2019 2:10:21 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 503

Thanks: 142 times
Was thanked: 66 time(s) in 64 post(s)
Another alternative is using Directory.Build.props file in root folder with e.g. below content
Code:

<Project>
    <PropertyGroup>
      <DefaultItemExcludes>*.ncrunchproject;</DefaultItemExcludes>
    </PropertyGroup>
</Project>
1 user thanked GreenMoose for this useful post.
Der-Albert.com on 3/1/2019(UTC)
IlyaC
#6 Posted : Thursday, February 28, 2019 2:14:36 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 7
Location: Norway

This might work, I can try this later, Remco solution works for me now :) So ideally if it were by default then we would not need to do anything at all.
Remco
#7 Posted : Thursday, February 28, 2019 9:43:56 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,974

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
The problem with doing this by default is that we've had people using the product for 8 years (most of them prior to .NET Core), and storing config files adjacent to project files is the way it's always been. So to suddenly change this by default for .NET Core projects would jarringly impact many people that are used to working this way.

Other tools (VS, Resharper, etc) follow the convention of placing config files adjacent to project files.

There are advantages to storing the files adjacent. If you have a project that is shared across multiple solutions, it's reasonable to expect its configuration would be shared too.
Der-Albert.com
#5 Posted : Friday, March 1, 2019 8:15:50 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/17/2011(UTC)
Posts: 175

Thanks: 8 times
Was thanked: 38 time(s) in 35 post(s)
GreenMoose;13154 wrote:
Another alternative is using Directory.Build.props file in root folder with e.g. below content
Code:

<Project>
    <PropertyGroup>
      <DefaultItemExcludes>*.ncrunchproject;</DefaultItemExcludes>
    </PropertyGroup>
</Project>


That's nice. I've did that with

Code:

  <ItemGroup>
    <None Remove="*.ncrunchproject" />
  </ItemGroup>


on the project level before. Because that did not work within the Directory.Build.props file. But the DefaultItemExcludes is the better place, also for *.DotSettings.
1 user thanked Der-Albert.com for this useful post.
GreenMoose on 3/1/2019(UTC)
IlyaC
#8 Posted : Friday, March 1, 2019 10:58:30 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 7
Location: Norway

Maybe then there can be a configuration option on top level for that? Now it's possible to do per solution, what if we can do that for all solutions maybe to not make it default option? I think more and more people switching to .net core will not find it seamless and would need to do that again and again, so that can be a nice workaround option?
Remco
#9 Posted : Friday, March 1, 2019 11:54:53 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,974

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
IlyaC;13163 wrote:
Maybe then there can be a configuration option on top level for that? Now it's possible to do per solution, what if we can do that for all solutions maybe to not make it default option? I think more and more people switching to .net core will not find it seamless and would need to do that again and again, so that can be a nice workaround option?


Sorry we have no plans to implement global config setting for this. Currently the solution setting is implemented using a relative path (for VCS support), so a global setting would require a whole parallel implementation and likely a new setting. We have too many configuration settings already. If you're unhappy about seeing a .ncrunchproject implicitly included in your solution file listing, there are a range of options available to allow you to remove it.
IlyaC
#11 Posted : Friday, March 1, 2019 12:15:40 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 7
Location: Norway

I understand, thanks for help anyway, the solution that can be applied is good enough
Der-Albert.com
#10 Posted : Monday, March 4, 2019 10:46:41 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/17/2011(UTC)
Posts: 175

Thanks: 8 times
Was thanked: 38 time(s) in 35 post(s)
IlyaC;13163 wrote:
Maybe then there can be a configuration option on top level for that? Now it's possible to do per solution, what if we can do that for all solutions maybe to not make it default option? I think more and more people switching to .net core will not find it seamless and would need to do that again and again, so that can be a nice workaround option?

The Solution of @GreenMoose is a per Solution solution. Works for all Projects in the hierarchy under the Directory.build.props file.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.107 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download