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

Notification

Icon
Error

NCrunch build breaks when building with SourceLink
Der-Albert.com
#1 Posted : Friday, June 8, 2018 10:46:18 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)
Hi,

when you include the SourceLink NuGet Package for VSTS.Git for Reference see here https://github.com/dotnet/sourcelink in a SDK Project.

Quote:

<PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-62925-02">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>


the i get the following error in build (local and grid note, v3.17)

Btw. i'm not able to copy and paste the error message from the NCrunch Test Window.

Quote:

NCrunch: This project was built on server 'whatever
..\..\..\..\Users\DerAl\.nuget\packages\microsoft.build.task.git\1.0.0-beta=62925-02\build\Microsoft.Build.Task.Git.targets (20, 5): Unable to locate repository containing repository 'C:\NCrunch Grid Node\5668\327\src\Myproject.Name.Foo


This makes seens, because the build taks try to guess the git repository uri at build time, but there is of cource none visible for NCrunch.

So i tried to obvious and added a condition to the package reference.
Quote:

<PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-62925-02" Condition="'$(NCrunch)' != '1'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>


But this does not help, i packed this inside a seperate ItemGroup with the condition, but this also not work.

Now this can be a problem on the MSBuild Side, or on the NCrunch side. Because of the highly optimized custom build on the NCrunch Side, i assume that is NCrunch which is ignoring Conditions on PackageReferences.
if not, then i file a bug on dotnet repository.


Remco
#2 Posted : Friday, June 8, 2018 11:55:10 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)
This is probably due to the way the MSBuild binding system works for PackageReferences.

To my knowledge, the PackageReference declaration doesn't really get used during the build of a project. Instead, it gets used to create the files under the 'obj' directory (specifically project.assets.json). This only happens during the Nuget restore step, which VS has complete control over and we can't safely execute ourselves.

So VS would run the Nuget restore step, probably using MSBuild integration and without the $(NCrunch) property set. NCrunch then picks up the generated project.assets.json and carries it on downstream. Because the actual binding happened before NCrunch was in the picture, the condition was never usefully evaluated.

So technically, this is between the chairs. We don't have a feasible way to take control of the restore step, and it we can't inject our own properties into VS's restore step because that would break your foreground solution.

I recommend looking at other options to disable this library under NCrunch. Maybe it has its own property that can be used as an off-switch, or you can trick it into failing silently rather than blowing up the build.
Der-Albert.com
#3 Posted : Monday, June 11, 2018 10:02:00 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)
After going through the details logs and the source link build targets source code

Quote:
<PropertyGroup Condition="'$(NCrunch)' == '1'">
<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
</PropertyGroup>


To make it build with NCrunch ;)
1 user thanked Der-Albert.com for this useful post.
Fresa on 7/7/2018(UTC)
Der-Albert.com
#6 Posted : Monday, June 11, 2018 10:14:55 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)
Maybe you should (can?) set that property if there is a Microsoft.SourceLink.* PackageReference in the project. Because SourceLink is something that MS will push in the Future.
1 user thanked Der-Albert.com for this useful post.
Remco on 6/11/2018(UTC)
trobinson-empactis
#4 Posted : Monday, June 25, 2018 1:13:59 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/25/2018(UTC)
Posts: 1
Location: United Kingdom

Der-Albert.com;12313 wrote:
After going through the details logs and the source link build targets source code

Quote:
<PropertyGroup Condition="'$(NCrunch)' == '1'">
<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
</PropertyGroup>


To make it build with NCrunch ;)


I'm running into the same problem and the above solution doesn't help. Do I just put it anywhere in my .csproj file(s)?
Der-Albert.com
#5 Posted : Monday, June 25, 2018 1:21:40 PM(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)
trobinson-empactis;12397 wrote:

I'm running into the same problem and the above solution doesn't help. Do I just put it anywhere in my .csproj file(s)?


Here is the complete *.csproj file, this is NOT the Project with the tests, this is the actual project which get's nuget packed.
A Company is only for removing personal information. I've done this in several of our nuget packages now.

Code:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <Version>0.0.0</Version>
    <PackageVersion>0.0.0</PackageVersion>
    <AssemblyInformationalVersion>0.0.1</AssemblyInformationalVersion>
    <Authors>A Company Software</Authors>
    <PackageProjectUrl>https://acompany.visualstudio.com/Shared/_git/Extensions.Fakes</PackageProjectUrl>
    <Description>Some helping base classes, for easier test setup. Using NSubstitute </Description>
    <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
    <Copyright>Copyright (C) 2017-2018 A Company Software</Copyright>
    <PackageTags>unit test, nsubstitute</PackageTags>
    <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <PropertyGroup Condition="'$(NCrunch)' == '1'">
    <EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
  </PropertyGroup>
  <PropertyGroup>
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Castle.Core" Version="4.2.1" />
    <PackageReference Include="JetBrains.Annotations" Version="11.1.0" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
    <PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-62925-02">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
    <PackageReference Include="NSubstitute" Version="3.1.0" />
    <PackageReference Include="System.Reflection.TypeExtensions" Version="4.4.0" />
  </ItemGroup>
</Project>

Remco
#7 Posted : Tuesday, June 26, 2018 12:20:23 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)
I just wanted to let you guys know that we have a change pending for the upcoming 3.18 release that will set this property automatically, so that changes to project files won't be necessary.
2 users thanked Remco for this useful post.
eriove on 6/26/2018(UTC), Fresa on 7/7/2018(UTC)
Remco
#8 Posted : Wednesday, August 1, 2018 8:19:56 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)
The just released v3.18 includes the fix for this issue.
1 user thanked Remco for this useful post.
Der-Albert.com on 8/6/2018(UTC)
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.064 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download