I'm updating a build to be compatible with .NET 4.5, and one of the changes I need to make is updating how I call ilmerge .
From the link above, this basically means changing:
/targetplatform:"v4,C:\windows\Microsoft.NET\Framework\v4.0.30319"
to:
/targetplatform:"v4,C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
In my MSBuild AfterBuild target I was generating the former using $(MSBuildToolsPath)
, like this:
/targetplatform:v4,$(MSBuildToolsPath)
What's the best way to translate this into the required /targetplatform:"v4,C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0"
path so that it works on x64, x86 or any unusual places it can wind up installed?
Add the GetReferenceAssemblyPaths task within your target. Have it save the output to a item name or property and replace the $(msbuildtoolsPath) with this new property. You can also add a condition check to determine what you need to pass to ILMerge.
<GetReferenceAssemblyPaths BypassFrameworkInstallChecks="False" TargetFrameworkMoniker=".NETFramework,Version=v4.0">
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="path" />
</GetReferenceAssemblyPaths>
If you can find a registry key that contains the information (or important elements of the information you need) then I'd use the $(Registry:<key name>[@<value name>])
syntax to obtain it.
http://blogs.msdn.com/b/msbuild/archive/2007/05/04/new-registry-syntax-in-msbuild-v3-5.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.