Wednesday, December 7, 2016

How to make a package


How to make a package


Tools needed: Nuget Package Explorer
Found at: https://docs.nuget.org/ndocs/tools/package-explorer

DotNet peek or some other way of determining dependencies for the package dlls

About NuGet packages in general:

Packages are zip files that happen to have the nupkg extention.

About the tool:

The NuGet Package Explorer is a GUI tool for creating and editing packages. It allows for a visual method of creating packages.

  1. Choose "Create a new package". Third option from the top of the "Common tasks" dialog.

  2. You'll get a screen shot like above to start with. Notice the circled buttons in the screen shot. Those are your modes for editing a package, edit metadata editing mode and metadata source editing mode.

  3. Click the pencil and paper button next to the green < > button. You will get what looks like above. Notice the blue circled areas on the screen shot. Those are the titles of the panes and the editing buttons for meta data, save and cancel.

  4. Drop the dll you want to package into the package contents side pane. You'll get the above popup too. Choose "Yes".
    1. If you want to add framework version checking to the package. Right click the pane, click "add lib folder" from the popup. Then right click the lib folder and click the "Add .Net folder" and select the version of the framework you want.
    2. If you already have a lib folder you create follow the same steps as a for starting it but you have to re-add the dll to the framework version folder you create or else the package could be corrupted.

  5. Once you've clicked "Yes" you're back to this screen with the dll now in a virtual folder.

  6. Package Dependencies - Click the edit assembly dependencies to add nuget package references to the package. You'll get a popup like above. Click the green plus sign. You can name the group by using the "Target framework" label group details. Click the little hand with a paper in the popup to navigate to the screen shot "Select Package". You may need to put in your package source and then click reload. Click the package in the list or find it using the search box. Click the package in the result list and click "open" or "show all versions" and select the version you need and then "open". Click the close button and now you're the proud owner of a package with package dependences.
  7. Save your package (Click the green check box and you'll save your package and you are now ready to save your package. Go to File, Save As. You'll see the version number in the package name. Its automatically populated from the version of your package. Leave it in the name, navigate to where you want to save it and then click save.) and deploy it to the build server nuget package location.

Friday, December 2, 2016

MSBuild script can't find the packages

Error:

You'll get an error stating it can't find the package even though its in the packages direction and brought down correctly.

Explanation:

The problem that has happened is that when the solution and subsequent projects were associated with it were created they were created in a way that doesn't match up with how things are laid out on the server. The packages compile locally because the packages directory is located relative to where the compiler and local (build script which is visual studio) understands it to be. The MSBuild scripts that are used on the build server know nothing o f this difference.

Solution:
So...
You're going to have to recreate your solution and project associations locally to match what's on the server. So this involves creating the solution file at the root of your web and service project folders. See the before and after images below.

Before:











After:



Further explanation:


As you can see the directory structure is a little different. There is no typical solution directory that you normally create.

Wednesday, September 7, 2016

Disabling/Enabling events jQuery

The problem:
I'd been recently looking at how to disable/enable client button clicks using jquery in the context of manipulating rows in a result set. You can use classes to enable/disabled functionality but that leaves the buttons still able to be clicked.

The solution:
So after some investigating and help from a co-worker we found using the ".on" and ".off" jquery methods to disable and enable the functionality of the buttons when a list of results was in view. You don't want a user to be trying to do some kind of action on some portion of a result set while nothing is selected.

So here's the disable code:

$('#idOfElement').off('click');
$('#idOfElement').addClass('disabled');

Enable code:

$('#idOfElement').on("click", function () {
                EventFunctionDeclaredElseWhere();
            });
            $('#idOfElement').removeClass('disabled');

As a bonus this keeps your markup clean because you don't use the onclick="" to bind the event.

jQuery references:
http://api.jquery.com/off/
http://api.jquery.com/on/

This simple and effective way of handling events will work in general. I like the simplicity and separation of concerns.

Tuesday, August 30, 2016

Learning Faster

I've been looking for a more efficient and effective way of learning and came accross the process by John Sonmez to learn in 10 steps. I think the person who did the youtube video added number 11. He has a whole course but I found a youtube video that covers it pretty well I bet since its the steps that I was really after.

https://youtu.be/02sDjtxgPjw?list=PL80vNsRjReW5EaFRQJVgzzC6hEgW0KVyX

My notes from the video:
    1. Get the big picture
      1. Learning is always tricky because when you first start to learn about something, you don't know enough about it to really understand what you need to learn. Do some basic research on the topics you want to learn about.
    2. Determine the scope
      1. Now that you know at least somewhat of an idea of what your topic is and how big it is, its time to narrow down your focus to determine what exactly you want to learn.
    3. Define the success
      1. The goal of this step is to come up with a clear and concise statement that will define success for your learning plan. For example: I can build a small application in c# that makes use of all the major language features.
    4. Find the resources
      1. Instead of reading a single book on a subject, try to gather many different resources to help you learn. Example: books, online videos, experts help, podcasts, source code, example projects, online documentation
    5. Creating a learning plan
      1. By now you should have a good idea of what subtopics you might wan tto learn about. You need to skim through the material you have and find a way to break down the topic into smaller sections.
    6. Filter resources
      1. Now that you know what you're going to learn and what order you're going to learn it in, its time to decide what resources you're going to use to accomplish the task, you have to cut down your resources to a number that you can manage.
    7. Learn enough to get started
      1. LDLT(Learn, Do, Learn, Teach)
      2. 2 common learning mistakes that most people make
        1. The problem of jumping in without knowing enough - Acting to soon
        2. The problem of preparing too much before umping in - acting to late
      3. You want to strike a balance between the two and learn just enough to get started
    8. Play around
      1. Play and experiment on your own. With this approach, ou learn by exploring and doing. As you play around, your brain naturally forms questions: How does this work? What happens if I do that? How do I solve this problem?
    9. Learn enough to do something useful
      1. Curiosity is a critical component of learning especially self-learning. This is your chance to really dig into the material and learn as much as you can and build something functional and useful
    10. Teach
      1. You only need to be one step ahead of some to teach them.
      2. You have to move out of your comfort zone and teach what you've learned to someone else
      3. Ways to learn
        1. Blog post
        2. Youtube videos
        3. Give PPT
        4. Attend/Conduct Meetups
        5. Join Online forums
    11. Stand out from the crowd
      1. Learn to stand out from the crowd
      2. Don't crib
      3. Do self learning. Don't depend on others
      4. Take the stand and start learning things on your own.


From this video I created a syllabus, as I like to call it, that covers the material I want to learn. I'll post that in a separate post later.


Tuesday, July 19, 2016

When MVC met Asp.net WebForms

I recently came across a scenario at work where I was getting a looping or cycling of authorization on a website.

Turns out this web.config setting was denying all the access while...

<authorization>
      <deny users="?"/>
    </authorization>

these sections

<location path="path1">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="path2">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="path3">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

 were giving permissions to the pertinent paths.

I found this out after soliciting some help from a coworker who'd been working on migrated Asp.net applications to MVC.

Friday, July 15, 2016

OAuth flows quick picture reference

I've been studying OAuth flows and found these images useful as references. They are not mine but I don't know the reference from where they came from.