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.

Paket restore silently fails when TargetFramework(s) are specified in Directory.Build.props and not csproj

See original GitHub issue

Description

When TargetFramework(s) are defined in Directory.Build.props Paket restore silently fails, it should be able to get it from msbuild at runtime.

Repro steps

Have Directory.Build.props in solution root folder e.g.:

<Project>
 <Import Project=".\Versions.props"/>
  <PropertyGroup>
      <FullFrameworkVersion>net462</FullFrameworkVersion>
   </PropertyGroup>
</Project>

and then use the property to define TargetFramework in underlying project files, e.g.:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
   <TargetFramework>$(FullFrameworkVersion)</TargetFramework>
    <AssemblyName>SomeAssembly</AssemblyName>
...
  </PropertyGroup>
  <Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>

Expected behavior

Paket restore shouldn’t silently fail. Ideally it should be able to get Framework information from msbuild from runtime.

Actual behavior

Paket restore is not able to get TargetFramework(s) information from project file and silently fails.

Known workarounds

Don’t define TargetFramework in Directory.Build.props . #3013

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
matthidcommented, Feb 13, 2018

@alfonsogarciacaro https://github.com/fsprojects/Paket/blob/7346d01d237ebe489a61bb699deb07ee8be8357b/src/Paket.Core/PaketConfigFiles/DependencyCache.fs#L34-L92

This basically is the implementation to get an order, implemented on package and on dll level. Basically all you need to have is a function getting dependencies. Here we use Mono.Cecil on dll-level and our own infos for package level

1reaction
vbfoxcommented, Feb 11, 2018

Copy pasting from slack, after discussing why generating dozen of .paket.resolved could be annoying if there was no detection (and that all supported framework were generated):

A single XML file could be generated and read like this :

<paket>
    <dep fw=";netstandard1.6;netstandard2.0;">Microsoft.NETCore.Platforms,2.0.1,Transitive,Main,false</dep>
    <dep fw=";netstandard1.6;netstandard2.0;">Microsoft.NETCore.Targets,2.0,Transitive,Main,false</dep>
</paket>
    <Target Name="Xml">
        <XmlPeek
            XmlInputPath="Test.xml" Query="/paket/dep[contains(@fw,'netstandard2.0')]/text()">
            <Output
                TaskParameter="Result"
                ItemName="ItemsFromFile"/>
        </XmlPeek>
        <Message Text="Hello @(ItemsFromFile)" Importance="high"/>
    </Target>

(Instead of the current ReadLinesFromFile)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Directory.Build.Props to change ...
So TargetFrameworkVersion is embedded in the net standard project as the value of net framework , so the build fails due to incompatibility. ......
Read more >
release-notes
... restore silently failed when TargetFramework(s) are specified in Directory.Build.props and not csproj - https://github.com/fsprojects/Paket/pull/3013 ...
Read more >
Target Framework defined in Directory.Build.props causes ...
I added the Directory.Build.props file to the ncrunch config to copy over as a needed file but still ncrunch gives me an error...
Read more >
Paket
A dependency manager for .NET with support for NuGet packages and git repositories. Why Paket? NuGet did not separate out the concept of...
Read more >
Paket 7.2.1
A dependency manager for .NET with support for NuGet packages and git repositories. Why Paket? NuGet did not separate out the concept of...
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