Compact Framework support in NuGet 1.2?

Mar 26, 2011 at 12:47 PM


I've been looking over 1.2 to see if support for .NET CF has been added. From what I can work out from the changeset (d3777a3a32a7) and the work item (219) this still hasn't been added as there is no use-case for .NET CF, and VS2010 doesn't support it anyway.

If I do understand the code correctly, then can I please ask that you reconsider this? We (and I'm sure a few others) work in a dev shop that uses VS2010 for Client/Web development of .NET4/.NET 3.5 apps, and can use NuGet for our common internal packages, but we also develop Embedded apps via Visual Studio 2008 targeting .NET 3.5 CF that use tweaked .NET CF versions of the *same* common packages. NuGet's framework targeting feature is perfect for us, but we can't use it as NuGet doesn't support CF.

I'm aware that we can't use the standard VS Add-In with VS2008 but SharpDevelop 4.1 does support NuGet and in turn, it supports VS2008 projects, so it's not outside our capability to use the core NuGet API to get round this issue, assuming the Core API supported .NET CF. If there is a fundamental issue I'm misunderstanding as to why .NETCF simply cannot be supported then I've not been able to work it out from the blogs, so can you please let me know :)

Many thanks

Mar 26, 2011 at 7:02 PM

We're pretty much done with 1.2 but we can surely do this for 1.3. If we knew what the target framework moniker was for .NET CF then we could add it to the list of supported frameworks.

Mar 26, 2011 at 8:17 PM

If you’d be willing to do that research, we can add the moniker to the list. J

Mar 28, 2011 at 9:28 AM

Ok, I'll see what I can do.

Mar 30, 2011 at 3:16 PM

Ok, I've done some digging. Some of this is new to me so if I state something that wrong, feel free to say so ;)

I've been going through the NuGet code to try to understand out how you work out what the current project is in VS2010 to get the current FrameworkMoniker. I think you use the ProjectFactory to parse it through the Microsoft.Build.Evaluation.Project class.

When you load up a standard VS2008 project (including .NET CF) into this Project class then the TargetFrameworkMoniker isn't available. If you hack the file to set the ToolsVersion to 4.0 (for a standard .NET 3.5 project) then the moniker becomes available and is correctly set. Unfortunately this trick doesn't work for a .NET CF project due to different MSBUILD targets (Microsoft.CompactFramework.CSharp.targets) that are embedded in the csProj (I'm still trying to work out why). Either way though, we can't hack the project file just to pass into the NuGet API, so the assumption is that the Core API will never support anything other than VS2010 compatible files (SharpDevelop 4.1 seems to generates VS2010 project files). I appreciate that this may not have been part of the original usecase, but then its unfortunate that .NET CF developers are stuck with VS2008 due to the decisions taken about the project formats VS2010 support, i.e. VS2008 is still an active product and will be for the foreseeable future.

If I'm correct in this, then this seems a bit of a limitation to the NuGet Core API, as it restricts custom extensions to make it work in other environments such as ours.

Since the original problem was how does NuGet identify which lib folder to get the package dll's from for .NET CF, I think the issue is possibly much wider in that NuGet doesn't support projects other than VS2010, and this is because it depends upon the TargetFrameworkMoniker which is a VS2010 only attribute.

I feel we need to break this dependency and have a "fall back" whereby if we cannot find a moniker when we interrogate the project we look for other known properties, such as TargetFrameworkVersion, PlatformFormFamilyName (i.e. "PowerPC") etc, to generate a moniker via NuGet, which will allow the Core API to work with non-VS2010 project files. Now .NET CF may cause a problem with this as its moniker may well be the same as the full version, but here a hack may be needed to create a custom moniker (and matching custom \lib\) so that we can create these.

Guys, if I've missed something fundamental and have gone off on the wrong track then apologies so could you give me any pointers? I'm still happy to do the legwork :)

Many thanks

Mar 30, 2011 at 5:25 PM

Yes you have missed something fundamental :).  The core API's (NuGet.Core.dll) have no dependency on VS2010. If you look closely we have an interface defined for the project system (IProjectSystem) and our VS implementations (in NuGet.VisualStudio.dll) rely on the "TargetFrameworkMoniker" attribute being there, but that's just a detail that's up to the implementation of the project system. NuGet doesn't work with VS2008 and if sharp develop does, then they need a way to produce a FramworkName for .net-cf and the core needs to recognize that name. It's a small change for us to detect new names but SharpDevelop needs to be able to produce names using whatever logic they see fit.

Mar 30, 2011 at 7:59 PM

Ah, oops :)

I've realised that SharpDevelop has "handily" removed support for .NET CF from their latest version, which is the only version that has NuGet support built in, so I can't work out how SharpDevelop gets round the issue for .NET CF as they don't need to :( SharpDevelop isn't something we use regularly but I was hoping I could use it as a suitable bridge to get the information you're after. Besides, I now realise it generates VS2010 compatible project files so I suspect NuGet will see it as VS2010.

From what you've said though, I'm unsure as to the way forward with this. My understanding is that NuGet can work out the correct .NET Framework (2.0, 3.5, 4.0, Silverlight etc.) from within VS2010 because VS2010 injects the Framework Moniker into the project file. This moniker is then passed to the NuGet Core API that can map it to the package \lib\ folder as it uses a naming convention based on the Moniker. So, although the Core itself has no dependency on VS2010 the information it requires can only be obtained from a VS2010 compatible project.

Even the just released version of Windows Embedded 7 Compact seems to require VS2008, so .NET CF projects are stuck - if my understanding is correct then its a bit frustrating as NuGet is perfect for this type of scenario. I'm happy to do all the work to wrap the NuGet Core to run under VS2008 or a console app (though support for VS2008 would be nice) but as the core engine expects a moniker format, which is not possible to identify, it'll never work. Unless, as a workaround, NuGet simply specifies that .NET CF apps need to use a value "XXXX" and this is interpreted as serving up the dll's appropiate to .NET CF. 

Again, happy to be told I'm missing the point again :)

Mar 30, 2011 at 10:31 PM

Forget VS2010 all we are doing is looking at framework names which can be anything. It just so happens that VS2010 provides this per project so the VS implementation uses it since it's readily available. If you were to create a VS2008 project system it could look at the platform or whatever logic you might use to figure out what the framework is and we both can agree on a framework name for .net-cf. To get more concrete imagine we decided that .netcf will use this framework name "NETFramework,Version=v1.0,Profile=CompactFramework", then we'd have a folder in the package say (net-cf) that would be for .net compact framework binaries. Now when we go to install your implementation of the project system would return that framework name if based on whatever logic (looking for powerpc and targetframework version or whatever).

Mar 31, 2011 at 10:13 PM


I think you're suggesting we just adopt a framework name that .NET CF users would have to ensure gets passed into NuGet somehow?

If so, I'm ok with that. I think I'm at a dead end with finding out if there is any Microsoft "official" Framework name that applies to .NET CF assemblies/projects - I don't think there is one, and you guys would be able to get one if there was easier than me I'd expect ;)

 "Profile=CompactFramework" seems the best option IMO since the "Version=" would cover the different .NET CF versions too.

Do you want me add this as an Issue Request?


Apr 1, 2011 at 12:39 AM

Only if you want to see if happen ;).

Apr 1, 2011 at 10:13 AM

Done. See

Thank you :)