Per Framework Content

Apr 4, 2011 at 6:47 PM

I have a scenario where I need to copy different source code based on the version of .NET that the package is being installed into. I need to make transformations on the source code as well. Is this supported? Can I just use the same folder structure under content as lib?

Coordinator
Apr 4, 2011 at 6:58 PM

No, we don't currently support that. There's a bug logged on that in our backlog: http://nuget.codeplex.com/workitem/221

Developer
Apr 4, 2011 at 7:10 PM

This isn't supported as yet but we have an issue tracking it:
http://nuget.codeplex.com/workitem/221

 

Apr 4, 2011 at 7:37 PM

In the mean time, how would you recommend I proceed?

Coordinator
Apr 4, 2011 at 7:38 PM

You can do some custom work in Install.ps1. I'd have to find some time to look into exactly *how* you would do it. It'll take some spelunking with $dte etc.

Apr 4, 2011 at 9:01 PM

I think we've got a reasonable solution worked out for the interim.  Thanks! I've voted up work item 221 as that will make things more maintainable for me in the future. Great work guys. The Caliburn.Micro community is really looking forward seeing the framework available on NuGet.

Coordinator
Apr 4, 2011 at 9:06 PM

Great! Is your solution something blog worthy as a tip for other NuGet users?

I’m glad it’s working out for you and hopefully we can make that part work better for you in the future. J

Phil

Apr 5, 2011 at 4:44 PM
Edited Apr 5, 2011 at 4:54 PM

Here's what we did. In the tools folder, we have platform-specific content folders. In the Install.ps1 we locate the appropriate folder, iterate the files and do some simple string replacement. Finally, we add the file to the solution. Here's the basic script:

 

param($rootPath, $toolsPath, $package, $project)

function get-content-path($contentRoot) {
	$moniker = $project.Properties.Item("TargetFrameworkMoniker").Value
	$frameworkname = new-object System.Runtime.Versioning.FrameworkName($moniker)

	$id = $frameworkname.Identifier

	if($id -eq ".NETFramework") { $relative = "NET40" }
	elseif($id -eq "Silverlight" -and $frameworkname.Profile -eq "WindowsPhone") { $relative = "SL40-WP" }
	elseif($id -eq "Silverlight" ) { $relative = "SL40" }
 
	[System.IO.Path]::Combine($contentRoot, $relative)
}
 
$contentSource = get-content-path($rootPath + "\tools")
$defaultNamespace = $project.Properties.Item("DefaultNamespace").Value

ls $contentSource | foreach-object { 
	$content = [System.IO.File]::ReadAllText($_.FullName)
	$content = $content.Replace('$safeprojectname$', $defaultNamespace)
	$content | out-file $_.FullName
	$project.ProjectItems.AddFromFileCopy($_.FullName)
}

 

Our folders are as follows under tools:

NET40

SL40

SL40-WP

Coordinator
Apr 5, 2011 at 5:04 PM

Very nice! If you don’t blog this, I will! Do you have a blog?

Apr 5, 2011 at 5:49 PM

Sure, I'll blog it. I'm on devlicio.us I'll see if I can get it up tonight.

Apr 9, 2011 at 1:46 AM

Here's the post: http://devlicio.us/blogs/rob_eisenberg/archive/2011/04/08/building-caliburn-micro-s-nuget-package.aspx

Apr 9, 2011 at 1:50 AM

Very nice work!

sent from my mobile

On Apr 8, 2011 7:46 PM, "EisenbergEffect" <notifications@codeplex.com> wrote:
> From: EisenbergEffect
>
> Here's the post: http://devlicio.us/blogs/rob_eisenberg/archive/2011/04/08/building-caliburn-micro-s-nuget-package.aspx
>
>
Apr 9, 2011 at 2:08 AM

Btw, the correct folder for WP7 project is SL3-WP.