MSBuild cant find resgen.exe

2019-07-21 08:40发布

问题:

I have a VM machine where I copied over the SDK files and path, went to the registry and added the keys to the registry, but I keep getting the error that resgen.exe cannot be found:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): 
error MSB3091: Task failed because "resgen.exe" was not found, or the correct 
Microsoft Windows SDK is not installed. The task is looking for "resgen.exe" 
in the"bin" subdirectory beneath the location specified in the Installation Folder 
value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\
Windows\v7.0A. You may be able to solve the problem by doing one of the following:  
1) Install the Microsoft Windows SDK.  
2) Install Visual Studio 2010.  
3) Manually set the above registry key to the correct location.  
4) Pass the correct location into the "ToolPath" parameter of the task.

I looked in the folder Microsoft\Microsoft SDKs\Windows\v7.0A and copied over the resgen.exe in practically every single net folder including the bin, but it keeps telling me that resgen.exe cannot be found. I have no clue what to do.

回答1:

Make sure your environment variable path includes the folder in which ResGen.exe resides



回答2:

Run Regedit to edit your registry. Look for the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows. If there is not already a Setting called "CurrentVersion", create a new registry setting "CurrentVersion" of type REG_SZ. Make sure it has the same value as the setting ProductionVersion in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A.

Make sure, you have the keys HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFX40Tools, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFX40Tools-x86 and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFX40Tools-x64 present in your registry and the value InstallationFolder set in each of them.



回答3:

I added the following SdkToolPath parameter to the project and that helped. Of course it is not a full solution as it will not work on the buildserver, but for now it works and I just don't check it in from my machine and it means I can do what I need to:

<GenerateResource SdkToolsPath="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools" Sources="@(TextResource)" OutputResources="@(TextResource->'$(OutDir)CommandStrings.resources')" />


标签: sdk msbuild