.NET Framework Bookmark and Share   
 index > MSBuild > Is there a way for an msbuild task locate an assembly using a Registry entry
 

Is there a way for an msbuild task locate an assembly using a Registry entry

If I already know the Registry entry which contains the path to an assembly, can I use this registry item to locate the assembly?

the assembly is located at
C:\export\bin\Debug\Tools\Configuration.BuildTask.dll

I have a registry entry something like this:
[HKEY_LOCAL_MACHINE\SOFTWARE\Configuration\Common\Paths]
"BuildTask"="C:\export\bin\Debug\Tools\Configuration.BuildTask.dll"

How can I access this from the project files build task?
Is there some way in the project file to extract the data from the registry entry first?

<UsingTask TaskName="Configuration.BuildTask" AssemblyName="Configuration.BuildTask" />

I do not want to create another Task to do this for me as the reason for this is because I will have problems locating the current locations of my Task assemblies (I'm not using the GAC for VS installation to store these assemblies).

learnerplates

No, at present there's no MSBuild support built in toread registry keys. (You'll likely see it in the next version, though)

I wonder whether this would help: can your installer create a single little stub .targets file that contains only this UsingTask (with the full path). It can put it under program files\msbuild\.....somewhere. Then all of your projects/targets can pull it in using the built in property $(MSBuildExtensionsPath).

Would that work?

Dan

"This posting provided AS-IS, with no warranties"

DanMoseley - MSFT

No, at present there's no MSBuild support built in toread registry keys. (You'll likely see it in the next version, though)

I wonder whether this would help: can your installer create a single little stub .targets file that contains only this UsingTask (with the full path). It can put it under program files\msbuild\.....somewhere. Then all of your projects/targets can pull it in using the built in property $(MSBuildExtensionsPath).

Would that work?

Dan

"This posting provided AS-IS, with no warranties"

DanMoseley - MSFT
Thanks Dan,
Yes that looks like a possibility alright, thanks alot for the idea.

I am presently setting up an installer, I had planned on it adding an entry to the registry and then our clients using that registry value to locate our assemblies.


My implementation however required that I provide the functionality to read the registry, because msbuild does not, in a Task assembly, this would require the client to include the Task in their project files with the UsingTask element and then use the result of the Task to point them to the assemblies. This is proving to be tricky however, as the UsingTask appears to be evaluated before the Targets.
I have an active post on the topic http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=686603&SiteID=1, "Syntax for Output property of MSBuild Target".


learnerplates

You can use google to search for other answers

Custom Search

More Threads

• How to make MSBuild find Lib and Include Files in C++ build?
• Is there any way to change the default location of the temporary project files?
• Copying files and folders using ItemGroup
• targets - when are they added to the msbuild directory? ( Vista RC2 )
• Possible to have per-configuration dependencies?
• Get erros when call MsBuild Engine in .NET 3.5
• String manipulation (how do I and/or improvement suggestion)
• vs2005 website release error
• MSB3061: Unable to delete file "bin\Debug\<<DLLName>>". Access to the path '<<ReferencePNE>>' is denied.
• URLDownloadToCacheFile failed (msbuild publish)