msbuild returns a Unhandled Exception: System.Runtime.InteropServices.COM Exception

SilverChips 71 Reputation points
2020-10-11T18:56:16.633+00:00

I currently have a VcxProj file that I am trying to build. I have been told that I can use msbuild to build that project.
This is what my VcxProj looks like

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(EnvironmentConfig)" />
  <PropertyGroup Label="Globals">
    <TargetName>MyCs</TargetName>
    <ResolveExportedSymbols>true</ResolveExportedSymbols>
    <ProjectGuid>{5s34D4F-3998-4C2D-97CC-168FR5BC3254}</ProjectGuid>
    <UsePrecompiledHeader>true</UsePrecompiledHeader>
  </PropertyGroup>
  <Import Project="$(XExtendedTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Label="Configuration">
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
    <ConfigurationType>DynamicLibrary</ConfigurationType>
  </PropertyGroup>
  <Import Project="$(XExtendedTargetsPath)\Microsoft.Cpp.props" />
  <ItemDefinitionGroup>
    <Link>
      <SubSystem>Windows</SubSystem>
      <AdditionalDependencies>
        %(AdditionalDependencies);
        $(MSVCRTLib);
        $(VCRuntimeLib);
      </AdditionalDependencies>
      <AdditionalOptions>
        %(AdditionalOptions)
        /WHOLEARCHIVE:MyCs.lib
      </AdditionalOptions>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClCompile Include="DllMain.cpp" />
    <ClInclude Include="stdafx.h" />
  </ItemGroup>
  <Import Project="$(XExtendedTargetsPath)\Microsoft.Cpp.targets" />
  <ItemGroup>
    <ProjectReference Include="xxxx" />
  </ItemGroup>
</Project>

To run the project I am doing this

MSBuild

The error I am getting is

Unhandled Exception: System.Runtime.InteropServices.COMException: Invalid value for registry (Exception from HRESULT: 0x80040153 (REGDB_E_INVALIDVALUE))
   at System.Runtime.InteropServices.RuntimeEnvironment.GetDeveloperPath()
   at System.AppDomain.SetupFusionStore(AppDomainSetup info, AppDomainSetup oldInfo)
   at System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile, String[] propertyNames, String[] propertyValues)

Any suggestions on why I might be getting this error ?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
34,851 questions
0 comments No comments
{count} votes