Support .NET Micro Framework Targets?

Apr 4, 2011 at 2:36 AM

I wonder if it would be easy to add support for .NET Micro Framework targets to Nuget.

I've been working on some projects for NETMF - mostly libraries to help out hobbyists who aren't as experienced with programming. One problem I run into in the community is a lack of experience with Visual Studio and managing source projects. If there was ever a community that could benefit from Nuget, I think hobbyists are it.

I created MicroLinq on CodePlex and I want to make it available on Nuget to NETMF developers as easily as possible and Nuget looks like the best bet.

 

Any guidance would be great.

 

Thanks,

-Erik

Developer
Apr 4, 2011 at 2:40 AM

After installing the .NET Microframework SDK, you probably have some new project templates for .net Micro specific projects. You can use the Package Manager console to figure out the target framework moniker that nuget can use to figure out project types (you'll have to wait until the next version to start using this though).

$p = Get-Project
$p.Properties.Item("TargetFrameworkMoniker").Value
Respond here with what the value is.

Apr 4, 2011 at 2:42 AM
Edited Apr 4, 2011 at 2:48 AM

 

.NETMicroFramework,Version=v4.1

 

That's it. Anything else I can retrieve?

Not sure if it's helpful, but I know the NETMF team is pushing out Alpha builds of version 4.2 with final expected later this year. After that it looks like it'll jump straight to version 5.

Developer
Apr 4, 2011 at 2:50 AM

Version doesn't matter, just the framework name and profile (if any).

Developer
Apr 4, 2011 at 2:52 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Developer
Apr 4, 2011 at 3:21 AM

The change is in the default branch. You can install the vsix from here:

http://ci.nuget.org:8080/guestAuth/repository/download/bt4/.lastSuccessful/VisualStudioAddIn/NuGet.Tools.vsix

Once you install that you should be able to install a package with assemblies that target NETMF. When you build a package, you can use the folder name netmf{version} (see the format http://nuget.codeplex.com/wikipage?title=Framework%20Profile%20Support)

lib/netmf41/foo.dll 

OR

lib/netmf4.1/foo.dll 

You should be able to build a package using the nuget.exe and you can try installing it into a .netmf project and let me know if it works.

Thanks!

Apr 4, 2011 at 3:24 AM

I'll give it a shot and report my findings.

Thanks for the quick-turn!
-Erik

Developer
Apr 4, 2011 at 3:45 AM

I actually tried it out myself :). Let me know if there are any issues/

Apr 4, 2011 at 4:47 AM

Success!

There was a little trial-and-error trying to include the proper files but I was able to build and run my test code in the emulator and it worked as expected.

For those who want to do something similar, this was my nuspec XML document.

<?xml version="1.0" encoding="utf-8"?>
<package>
  <metadata>
    <id>VikingErik.NetMF.MicroLinq</id>
    <version>0.1.7</version>
    <authors>Erik Noren</authors>
    <description>A small implementation of LINQ on the .NET Micro Framework.</description>
    <language>en-US</language>
    <licenseUrl>http://microlinq.codeplex.com/license</licenseUrl>
    <projectUrl>http://microlinq.codeplex.com/</projectUrl>
  </metadata>
  <files>
    <file src="VikingErik.NetMF.MicroLinq\bin\Release\VikingErik.NetMF.MicroLinq.dll" target="lib/netmf/41/VikingErik.NetMF.MicroLinq.dll" />
    <file src="VikingErik.NetMF.MicroLinq\bin\Release\VikingErik.NetMF.MicroLinq.pdb" target="lib/netmf/41/VikingErik.NetMF.MicroLinq.pdb" />
    <file src="VikingErik.NetMF.MicroLinq\bin\Release\le\*" target="lib/netmf/41/le/" />
    <file src="VikingErik.NetMF.MicroLinq\bin\Release\be\*" target="lib/netmf/41/be/" />
  </files>
</package>

Developer
Apr 4, 2011 at 4:55 AM
VikingErik wrote:

Success!

There was a little trial-and-error trying to include the proper files but I was able to build and run my test code in the emulator and it worked as expected.

For those who want to do something similar, this was my nuspec XML document.

 

<?xml version="1.0" encoding="utf-8"?>
<package>
  <metadata>
    <id>VikingErik.NetMF.MicroLinq</id>
    <version>0.1.7</version>
    <authors>Erik Noren</authors>
    <description>A small implementation of LINQ on the .NET Micro Framework.</description>
    <language>en-US</language>
    <licenseUrl>http://microlinq.codeplex.com/license</licenseUrl>
    <projectUrl>http://microlinq.codeplex.com/</projectUrl>
  </metadata>
  <files>
    <file src="VikingErik.NetMF.MicroLinq\bin\Release\VikingErik.NetMF.MicroLinq.dll" target="lib/netmf/41/VikingErik.NetMF.MicroLinq.dll" />
    <file src="VikingErik.NetMF.MicroLinq\bin\Release\VikingErik.NetMF.MicroLinq.pdb" target="lib/netmf/41/VikingErik.NetMF.MicroLinq.pdb" />
    <file src="VikingErik.NetMF.MicroLinq\bin\Release\le\*" target="lib/netmf/41/le/" />
    <file src="VikingErik.NetMF.MicroLinq\bin\Release\be\*" target="lib/netmf/41/be/" />
  </files>
</package>

 

The 41 shouldn't be a sub folder of netmf it's part of the name. i.e

change

lib/netmf/41 to lib/netmf41

Apr 4, 2011 at 5:05 AM

Oh, thanks, I'll update it tomorrow and add the other projects that are in the project solution. It might be a good reference for others.

This was my first Nuget package build attempt. I'm guessing there's a shorter way to do what I've done but I stopped once it was working. I'm overdue for bed!

Again, I really appreciate your effort and guidance. I'm going to be a big advocate for Nuget in the NETMF community as soon as it's in an official release.

-Erik

Apr 15, 2011 at 5:19 PM

Just to loop back in case anyone was doing something similar, the nuspec file I used to make the package for my project on Nuget is below. This is what I used to publish to the Nuget feed. (You won't be able to use Nuget to get it unless you're making a NETMF project and have Nuget 1.3 or greater installed.)

To explain, I have a solution with 4 projects, each of which builds to a set of files needed for NETMF projects. This is to keep the libraries individually small so users developing with them don't waste space on things they aren't using.  Only two of the projects make sense to package together and make available. The other two are considered utility or example code. My nuspec file lives in the root solution directory which is above the projects. The XML below shows how I package all the necessary files together so a user can add the project reference, build and deploy without any other intervention.

The NETMF target requires the LE and BE (little endian and big endian, respectively) folders with same-named files as the project DLL. This is just a detail / consequence of programming for embedded systems. It might look like I'm being overly specific with the file names but this is necessary since the PrebuiltDelegates project depends on MicroLinq and I receive duplicate file name errors if I don't do it this way. When I build ZIP files for release on CodePlex, I manually remove the duplicate libraries from all the PrebuiltDelegates directories - this layout does it for me automatically.

-Erik

<?xml version="1.0" encoding="utf-8"?>
<package>
 <metadata>
   <id>MicroLinq</id>
   <version>0.2.5</version>
   <authors>Erik Noren</authors>
   <description>A small implementation of LINQ on the .NET Micro Framework.</description>
   <language>en-US</language>
   <licenseUrl>http://microlinq.codeplex.com/license</licenseUrl>
   <projectUrl>http://microlinq.codeplex.com/</projectUrl>
 </metadata>
 <files>
   <file src="VikingErik.NetMF.MicroLinq\bin\Release\VikingErik.NetMF.MicroLinq.*" target="lib/netmf41/" />
   <file src="VikingErik.NetMF.MicroLinq\bin\Release\le\VikingErik.NetMF.MicroLinq.*" target="lib/netmf41/le/" />
   <file src="VikingErik.NetMF.MicroLinq\bin\Release\be\VikingErik.NetMF.MicroLinq.*" target="lib/netmf41/be/" />
   <file src="VikingErik.NetMF.MicroLinq.PrebuiltDelegates\bin\Release\VikingErik.NetMF.MicroLinq.PrebuiltDelegates.*" target="lib/netmf41/" />
   <file src="VikingErik.NetMF.MicroLinq.PrebuiltDelegates\bin\Release\le\VikingErik.NetMF.MicroLinq.PrebuiltDelegates.*" target="lib/netmf41/le/" />
   <file src="VikingErik.NetMF.MicroLinq.PrebuiltDelegates\bin\Release\be\VikingErik.NetMF.MicroLinq.PrebuiltDelegates.*" target="lib/netmf41/be/" />
 </files>
</package>