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

Paket fails on projects that target multiple frameworks #2496

Closed
teo-tsirpanis opened this issue Jul 8, 2017 · 21 comments
Closed

Paket fails on projects that target multiple frameworks #2496

teo-tsirpanis opened this issue Jul 8, 2017 · 21 comments

Comments

@teo-tsirpanis
Copy link
Contributor

Description

I made a very simple project that only depends on one package. It targets both .NET Standard 1.6 and .NET Framework 4.6.2. Running paket install and paket restore gives no errors. But when it run dotnet restore, Paket says this:

C:\code\paket_bug\.paket\Paket.Restore.targets(22,5): error MSB3073: The command ""C:\code\paket_bug\.paket\paket.exe" restore --project "C:\code\paket_bug\Hello.fsproj" --target-framework " exited with code 1. [C:\code\paket_bug\Hello.fsproj]

The target framework is empty!

Repro steps

hellp.fsproj

<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net462;netstandard1.6</TargetFrameworks>
  </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>

paket.dependencies

framework: net462, netstandard1.6

source https://api.nuget.org/v3/index.json

nuget Chessie

paket.references
Chessie

Possible cause

In the project file, there is a TargetFrameworks section, not the TargetFramework that paket.restore.targets asks for. paket.restore.targets should handle it somehow. On projects that target one framework and have the TargetFramework property, Paket works like a charm.

Version information

paket --version: Paket version 5.5.3
dotnet --version: 2.0.0-preview2-006497

@forki
Copy link
Member

forki commented Jul 8, 2017

This sounds like an issue with dotnet cli itself. Why is it not providing the target framework information?

@teo-tsirpanis
Copy link
Contributor Author

Which of them? .NET Standard 1.6 or .NET Framework 4.6.2? I will test it with the stable CLI.

@forki
Copy link
Member

forki commented Jul 8, 2017

We I tested multi target it actually called paket restore two times. One with every framework

@matthid
Copy link
Member

matthid commented Jul 8, 2017

We should probably use the TargetFrameworks variable. the TargetFramework variable only is syntactic sugar afaik.

@matthid
Copy link
Member

matthid commented Jul 8, 2017

/cc @enricosada

@matthid
Copy link
Member

matthid commented Jul 8, 2017

Or a breaking change in 2.0.0-preview2-006497?

@teo-tsirpanis
Copy link
Contributor Author

Or a breaking change in 2.0.0-preview2-006497?

I guess so. But I uninstalled the preview CLI and the same error appeared. I also tried to "bisect" the bug by trying with Paket 5.0.0, but it happened again. I guess it's something else in my machine that changed. In the past I could make cross-framework packages with Paket and without problem.

We should probably use the TargetFrameworks variable. the TargetFramework variable only is syntactic sugar afaik.

I will try to see if it does anything. Currently, my project only targets .NET 4.6.2. 😢

@teo-tsirpanis
Copy link
Contributor Author

I will try to see if it does anything. Currently, my project only targets .NET 4.6.2. 😢

No luck. 🙁

@Mpdreamz
Copy link
Contributor

We should probably use the TargetFrameworks variable. the TargetFramework variable only is syntactic sugar afaik.

Can confirm that the plural works $(TargetFrameworks). I was hit by this error too:

error : argument '--target-framework' must be followed by <framework>.

.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.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.1

@forki
Copy link
Member

forki commented Jul 14, 2017

@Mpdreamz can you please upload a zip with a repro

@Mpdreamz
Copy link
Contributor

Working on a PR with integration test 😄 hopefully I get somewhere otherwise will upload a repro

@forki
Copy link
Member

forki commented Jul 14, 2017

even better ;-)

@teo-tsirpanis
Copy link
Contributor Author

The bug seems fixed with Paket 5.7.0.
However, why is Paket run three times while dotnet restoreing a project that targets two frameworks?

@forki
Copy link
Member

forki commented Jul 17, 2017

I think one is for discovering the cli tools

@seanamosw
Copy link
Contributor

With the latest Paket.Restore.targets I still wasn't able to get this to work.

eg.

<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.6;net461</TargetFrameworks>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>
  ...
C:\myproject\.paket\Paket.Restore.targets(23,5): error MSB3073: The command ""C:\myproject\.paket\paket.exe" restore --project "C:\myproject\myproject.fsproj" --target-framework """ exited with code 1. [C:\myproject\myproject.fsproj]

However, this works:

<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.6;net461</TargetFrameworks>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>
  <ItemGroup>
    <TargetFrameworks Include="netstandard1.6" />
    <TargetFrameworks Include="net461" />
  </ItemGroup>
  ...

This makes sense to me, given the usage of the @ in Paket.Restore.targets. As far as I knew @ only worked with ItemGroups. Unless there is "magic" where the dotnet cli/msbuild is supposed to convert the TargetFrameworks property into items?

@forki
Copy link
Member

forki commented Jul 18, 2017

@seanamosw oh. can you please suggest a PR with a fix to the targets file so that thefirst thing works?

@forki
Copy link
Member

forki commented Jul 18, 2017

@Mpdreamz do you see the issue?

@Mpdreamz
Copy link
Contributor

Mpdreamz commented Jul 18, 2017

I have not yet tested the new release or the updates but my original commit splitted the tfm

Mpdreamz@513491b

Which then allows @ to itterate each item.

Now we pass the string verbatim and let paket expand it internally (:+1:) it should be $(TargetFrameworks) here https://github.com/fsprojects/Paket/blob/master/.paket/Paket.Restore.targets#L23

@forki
Copy link
Member

forki commented Jul 18, 2017

ok changing it right now!

@forki
Copy link
Member

forki commented Jul 18, 2017

fixed. @seanamosw can you please try it?

@forki forki closed this as completed Jul 18, 2017
@seanamosw
Copy link
Contributor

Can confirm the change to $(TargetFrameworks) works. I had been using this exact change as temporary workaround locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants