Jan 31, 2012 at 2:36 AM
Edited Jan 31, 2012 at 3:25 AM
To anyone who reads this further on, I've done a lot of work with colleagues on this issue and discovered the following:
The scenario is caused by an System Environment Variable being created by SQL Server at install - this environment variable overwrites the local Platform variable used by MSBuild. This means it tries to 'build' using the wrote platform (doesn't
tell you this unless you try an msbuild which gives a more obvious error) and therefore doesn't know the TargetPath.
The problem is 100% machine specific and many users will not even know they have an issue until they either try and retrieve the TargetPath due to a coding requirement or use a solution which uses it (such as nuget BuildPackage).
What won't work:
Uninstalling VS, SQL Server, nuget etc.
Reinstalling your machine if you install SQL Server first (we had SQL Server 2008 R2 full install) followed by Visual Studio.
What we have found to work twice:
Close Visual Studio and stop looking at the errors in there.
Use msbuild (run from Visual Studio 2010 Command Prompt) - build your solution. If you get errors about building for an invalid configuration then this solution is for you. In our case it was trying to a configuration for Target Platform "BPC"
(which wasn't ours).
Open the windows system variables (requires Admin priveleges).
Find the system variable called 'Platform' and remove it. (In our case, this variable had 'BPC' set, hence the previous error in msbuild)
Restart (important - the fix will appear not to work otherwise)
Try using msbuild again - it should work now.
Open Visual Studio and try building again - it should work now, complete with nuget package creation as part of PostBuild.
Disclaimer: The BPC environment key is used by SQL Server Integration Services (SSIS) - I don't yet know what it's removal will do to SSIS. If SSIS is crucial to your development stack, then I recommend further investigation.
I would really like to hear from other people if this helps them. If it doesn't help you, please say so - I will continue to look at what I missed.