Visual Studio项目文件指定多个导入

Pau*_*per 1 c# windows-installer wix visual-studio-2008

我有一个C#项目.我想构建一个exe或MSI,具体取决于配置.

MSI定义为

<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">MSI</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
  <ProductVersion>9.0.30729</ProductVersion>
  <ProjectGuid>{DCB76E90-6364-4DFB-B568-3680EE4F9C80}</ProjectGuid>
  <SchemaVersion>2.0</SchemaVersion>
  <OutputName>Project1</OutputName>
  <OutputType>Package</OutputType>
  <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
  <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'MSI|x86' ">
  <OutputPath>bin\MSI2\</OutputPath>
  <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
  <Compile Include="MyWxs.wxs" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)

问题是,当我尝试两者兼而有之时

<Import Project="$(WixTargetsPath)" />
Run Code Online (Sandbox Code Playgroud)

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Run Code Online (Sandbox Code Playgroud)

错误

A problem occurred while trying to set the "TargetType" parameter for the IDE's in-process compiler.
Invalid target type "package" for /target: must specify 'exe', 'winexe', 'library', or 'module'.
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

Rob*_*ing 5

您无法将这两个目标导入单个项目.他们都希望能够处理这些Compile物品(使用完全不同的工具,即:candle.execsc.exe).你需要单独的项目.通常,Microsoft.CSharp.targets进入.csproj并Wix.targets进入.wixproj.