3

With the recent release of Polymer 1.0 I was hoping to use the Paper Elements in a ASP.NET MVC/Microsoft Stack, or at least check them out.

I have used nuget in the Visual Studio package manager to attempt to install polymer:

    PM> Install-Package polymer
    Installing 'polymer 1.0.0'.
    Successfully installed 'polymer 1.0.0'.
    Adding 'polymer 1.0.0' to Eqs.Mvc.Web.
    Successfully added 'polymer 1.0.0' to Eqs.Mvc.Web.

    PM> Install-Package paper-elements
    ...long long list of dependency imports

When I try to import paper-elements.html I notice that in paper-elements.html there are missing files and files in the wrong locations. For example in paper-elements.html:

<link rel="import" href="../polymer/polymer.html">

is actually located in the project at the scripts root:

<link rel="import" href="../polymer.html">

I get a lot of 404 errors. Did I import the packages incorrectly?

MEC
  • 1,690
  • 1
  • 17
  • 23
  • tl;dr I installed polymer 1.0 and paper-elements 1.0 using nuget in VS; references from paper-elements to polymer are wrong. Help. – MEC Oct 03 '15 at 16:35

3 Answers3

10

Don't use NuGet to get polymer elements (as it's not maintained by Google so it's not up-to-date), use Bower instead.

Prior to ASP.NET 5

  1. Go to NuGet's Package Management Console and install Bower.

    PM> Install-Package Bower

  2. Navigate to your web project folder in File Explorer and then Shift + Right Click anywhere to select Open command window here in the context menu.

  3. Inside the command prompt, run the following commands one after another.

    bower init

    bower install --save Polymer/polymer

    bower install --save PolymerElements/paper-elements

  4. Whenever there's a new version, run the following command.

    bower update.

ASP.NET 5

It's a lot simpler in ASP.NET 5, since the project already adds a bower.json file for you. So you just need to add the dependencies there -

{
  "name": "Portal",
  "private": true,
  "dependencies": {
    "polymer": "^1.1.3",
    "paper-elements": "PolymerElements/paper-elements#^1.0.3",
    ...
}

Once all dependencies are added, go to your Visual Studio web project and enable Show All Files. You will see a folder called bower_components, just include it into your project.

Have a look at this question I asked too.

Community
  • 1
  • 1
Justin XL
  • 38,763
  • 7
  • 88
  • 133
  • I installed Bower and did the init and install commands. I see paper-element directories but no files. Any ideas? Thanks! – MEC Oct 06 '15 at 12:57
  • 1
    What's the output when you do bower install --save polymerelements/paper-elements? Maybe try running cmd prompt using admin privileges? – Justin XL Oct 06 '15 at 16:38
  • That helped a lot!! after running cmd in admin mode I ran bower cache clean bower update and I seem to have downloaded all of the files, however they are in a weird place under my project in: .bin\public\lib\polymer I am guessing that my bower.json settings are not pointing to my project directory. That should not be too hard to find. – MEC Oct 06 '15 at 22:15
  • You know what, don't use the path from the package management console, use the path of your web project. And then do the commands from there. – Justin XL Oct 06 '15 at 22:33
  • Just updated the answer. So try using the path of your web project folder and it should download the files to the right folder! – Justin XL Oct 06 '15 at 22:40
2

Alternatively my company, FrostAura Consolidated now manages a package that you might find useful. This package scaffolds all core and paper components with a demo of how to create a custom web component with automated documentation and unit testing. Check it out at https://www.nuget.org/packages/FrostAura.Dynamics.Polymer.Kickstart/

Dean Martin
  • 1,223
  • 3
  • 18
  • 27
  • This worked. Now I have to try to figure out how to bind elements such as paper-input to my model... – MEC Jan 15 '16 at 15:46
  • The answer to my how to bind question is here: http://stackoverflow.com/questions/34815159/how-do-you-bind-polymer-elements-to-a-model-in-asp-net/34818257#34818257 – MEC Jan 18 '16 at 12:43
0

you may need run Set-ExecutionPolicy Unrestricted in windows powershell to allow Bower install scripts to run...

yob
  • 528
  • 4
  • 9