question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Group conditions for dotnet sdk projects

See original GitHub issue

Description

I’m trying to move this type of code to from nuget to paket

  <ItemGroup Condition="'$(TargetFramework)'=='net45'">
    <PackageReference Include="FSharp.Core" Version="4.0.0.*" />
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)'=='netstandard1.6'">
    <PackageReference Include="FSharp.Core" Version="4.1.*" />
  </ItemGroup>

However when I move to setup below I get this error and similar (truncated since it’s very long)

/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error : Package System.Globalization.Calendars 4.3.0 is not compatible with net45 (.NETFramework,Version=v4.5). Package System.Globalization.Calendars 4.3.0 supports: [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - monoandroid10 (MonoAndroid,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - monotouch10 (MonoTouch,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - net46 (.NETFramework,Version=v4.6) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - netstandard1.3 (.NETStandard,Version=v1.3) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - xamarinios10 (Xamarin.iOS,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - xamarinmac20 (Xamarin.Mac,Version=v2.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - xamarintvos10 (Xamarin.TVOS,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - xamarinwatchos10 (Xamarin.WatchOS,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]

Repro steps

paket.dependencies

group full
    condition: FULL
    framework: net45
    source https://www.nuget.org/api/v2
    nuget FSharp.Core 4.0.0.1
group core
    condition: CORE
    framework: netstandard1.6
    source https://www.nuget.org/api/v2
    nuget FSharp.Core 4.1.17

paket.references

group core
FSharp.Core
group full
FSharp.Core

fsproj

<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.6;net45</TargetFrameworks>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)'=='net45'">
     <FULL>true</FULL>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)'=='netstandard1.6'">
    <CORE>true</CORE>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Library.fs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
  </ItemGroup>
  <Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>

Then run dotnet restore on src\MyLib

https://github.com/TheAngryByrd/paketConditonNetcore

Expected behavior

Ability to restore and build net45 and netstandard1.6 with different versions of FSharp.Core

Actual behavior

/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error : Package System.Globalization.Calendars 4.3.0 is not compatible with net45 (.NETFramework,Version=v4.5). Package System.Globalization.Calendars 4.3.0 supports: [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - monoandroid10 (MonoAndroid,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - monotouch10 (MonoTouch,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - net46 (.NETFramework,Version=v4.6) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - netstandard1.3 (.NETStandard,Version=v1.3) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - xamarinios10 (Xamarin.iOS,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - xamarinmac20 (Xamarin.Mac,Version=v2.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - xamarintvos10 (Xamarin.TVOS,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]
/usr/local/share/dotnet/sdk/1.0.1/NuGet.targets(97,5): error :   - xamarinwatchos10 (Xamarin.WatchOS,Version=v1.0) [/Users/jimmybyrd/Documents/GitHub/classLibTemplate/Content/src/MyLib/MyLib.fsproj]

Known workarounds

Use nuget 😭

Version info

Mono JIT compiler version 4.8.1 (mono-4.8.0-branch/22a39d7
.NET Command Line Tools (1.0.1)

Product Information:
 Version:            1.0.1
 Commit SHA-1 hash:  005db40cd1

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.11
 OS Platform: Darwin
 RID:         osx.10.11-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.1
Paket version 5.0.0-beta010

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
Shmewcommented, Nov 23, 2020

Shouldn’t this be paket.dependencies ?

Yes, that was a typo on my part! I fixed it.

Looks like preprocessor symbols? But I couldn’t even find documentation on condition syntax.

Yes, it doesn’t seem to be documented at all. I figured this out by spending a bunch of time digging through the paket code and ancient issues 😅.

2reactions
oldercommented, Nov 24, 2020

@forki could you comment on this? Is this something which should be documented here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

MSBuild reference for .NET SDK projects
Reference for the MSBuild properties and items that are understood by the .NET SDK.
Read more >
MSBuild Conditions
A condition that contains an @-expression such as @(SomeItems) is expanded in item groups at the top level and in targets. Items can...
Read more >
.net core - How to I write an msbuild condition that applies ...
1 Answer 1 ... You can use the UsingMicrosoftNETSdkWeb property that is set to true whenever a project is using Sdk="Microsoft.NET.Sdk.Web" .
Read more >
Target frameworks in SDK-style projects - .NET
When you target a framework in an app or library, you're specifying the set of APIs that you'd like to make available to...
Read more >
Demystifying the SDK Project - Dan Siegel
Dan Siegel - Building Better Apps - The new SDK Style projects really help ... Well ItemGroup's are all about grouping Items we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found