Bug 26703 - Microsoft.Net.Http package not installed correctly
Summary: Microsoft.Net.Http package not installed correctly
Status: RESOLVED ANSWERED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: NuGet ()
Version: unspecified
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Matt Ward
URL:
Depends on:
Blocks:
 
Reported: 2015-02-03 15:51 UTC by Paul Read
Modified: 2015-09-02 06:42 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
XS giving a warning about a missing using on a using statement! (115.10 KB, image/png)
2015-02-03 15:52 UTC, Paul Read
Details
Diagnostic output (156.16 KB, text/plain)
2015-02-03 16:07 UTC, Paul Read
Details
Diagnostic output from ResilientServices (222.13 KB, text/plain)
2015-02-03 16:39 UTC, Paul Read
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Paul Read 2015-02-03 15:51:59 UTC
Description of Problem:
See attached image



Steps to reproduce the problem:
1. Create PCL 
2. Add microsoft http client
3. add modernhttpclient
4. add some code to use ModernHttpClient
5. IDE helpful offers to add 'using ModernHttpClient'

Actual Results:
At compile time the using statement added by the IDE fails to compile!


Expected Results:
compiles or rejects compilation with a much more meaningful message pointing to the true issue (which I don't know what that is at this moment)

How often does this happen? 
Repeatably


Additional Information:
If you know the work around I'd love to know asap
Comment 1 Paul Read 2015-02-03 15:52:59 UTC
Created attachment 9627 [details]
XS giving a warning about a missing using on a using statement!
Comment 2 Mikayla Hutchinson [MSFT] 2015-02-03 16:00:49 UTC
It's not really clear what the problem is here.

The MordernHttpClient classes are in the ModernHttpClient namespace, so it seems XS behaviour is okay. My guess would be that the reference isn't making it to the compiler for some reason. Could you do a build with diagnostic verbosity and attach it?
Comment 3 Paul Read 2015-02-03 16:04:01 UTC
>Could you do a build with diagnostic verbosity and attach it?

Sure

How?
Comment 4 Paul Read 2015-02-03 16:07:40 UTC
Created attachment 9628 [details]
Diagnostic output

Looks like I might have a packaging issue
Comment 5 Mikayla Hutchinson [MSFT] 2015-02-03 16:11:39 UTC
Yup:
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3253: The currently targeted framework ".NETPortable,Version=v4.5,Profile=Profile78" does not include "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which the referenced assembly "System.Net.Http.Extensions" depends on. This caused the referenced assembly to not resolve. To fix this, either (1) change the targeted framework for this project, or (2) remove the referenced assembly from the project.

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3253: The currently targeted framework ".NETPortable,Version=v4.5,Profile=Profile78" does not include "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which the referenced assembly "ModernHttpClient" depends on. This caused the referenced assembly to not resolve. To fix this, either (1) change the targeted framework for this project, or (2) remove the referenced assembly from the project.

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3253: The currently targeted framework ".NETPortable,Version=v4.5,Profile=Profile78" does not include "System.Net.Requests, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which the referenced assembly "ModernHttpClient" depends on. This caused the referenced assembly to not resolve. To fix this, either (1) change the targeted framework for this project, or (2) remove the referenced assembly from the project.
Comment 6 Mikayla Hutchinson [MSFT] 2015-02-03 16:14:50 UTC
Not sure what to assign this to, TBH. That's coming from the *Microsoft* MSBuild targets.
Comment 7 Paul Read 2015-02-03 16:20:59 UTC
I still don't know the fix as this PCL project has the same settings as the ResilientServices example, namely: 

PCL 4.5 - Profile78

The ResilientServices PCL builds fine
Comment 8 Mikayla Hutchinson [MSFT] 2015-02-03 16:33:16 UTC
It seems particularly odd that System.Net.Http.Extensions.dll can't resolve System.Net.Http.dll when they both come from the same NuGet package, which is also provided by Microsoft.
Comment 9 Paul Read 2015-02-03 16:39:37 UTC
Created attachment 9629 [details]
Diagnostic output from ResilientServices

Working diagnostic build attached.

Differences that might be relevant (but meaningless to me):

    AutoUnifyAssemblyReferences
    FullFrameworkFolders:
Comment 10 Mikayla Hutchinson [MSFT] 2015-02-03 16:40:58 UTC
I think this is because the XS NuGet package manager didn't run the PowerShell install scripts for Microsoft.Bcl.Build, which would add this to you project file:

<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
  <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
    <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
    <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
  </Target>
Comment 11 Mikayla Hutchinson [MSFT] 2015-02-03 16:41:52 UTC
Yup, your ResilientServices log has the Microsoft.Bcl.Build targets.
Comment 12 Paul Read 2015-02-03 16:54:24 UTC
Yea!

Not sure where I went wrong I just used Add package  to select MS HTTP Client Libraries and ModernHttpClient 

Did I do something wrong?
Comment 13 Paul Read 2015-02-03 16:55:03 UTC
(Adding that import stuff to the PCL project fixed it)
Comment 14 Matt Ward 2015-02-03 17:39:44 UTC
You did nothing wrong. Xamarin Studio does not currently support running PowerShell scripts that a NuGet package may include.

When you install Microsoft.Bcl by default NuGet will install the lowest version of Microsoft.Bcl.Build which it considers compatible. That happens to be 1.0.14 which uses PowerShell scripts to add the Import statements to the project. The latest version of Microsoft.Bcl.Build 1.0.21 does not use PowerShell and instead relies on NuGet's built in support for adding Imports so that version works with Xamarin Studio and will add the imports to the project.

So right now the workaround would be to either install Microsoft.Bcl.Build first, which will install the latest version 1.0.21, or update Microsoft.Bcl.Build after installing Microsoft.Bcl to get the latest version. Doing this would add the Imports to the project file.
Comment 15 Matt Ward 2015-09-02 06:42:30 UTC
Workaround was specified in comment #14. The older version of Microsoft.Bcl.Build is not cross-platform since Xamarin Studio does not support PowerShell scripts out of the box. Marking this as answered.