今天我要将x64平台添加到我的解决方案中,但遇到了这个问题。
在我的情况下,错误信息如下:
“为默认目标构建 $/ProjectDirectory/ProjectName.csproj。
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (484):未为项目 ProjectName.csproj 设置 OutputPath 属性。请确保您已为此项目指定了有效的 Configuration 和 Platform 组合。Configuration='Debug' Platform='x64'。您可能会看到此消息是因为您正在尝试构建一个没有解决方案文件并且已指定不存在于该项目中的非默认 Configuration 或 Platform 的项目。”
我知道 OutputPath 应该没问题,因为这是一个现有的、工作正常的 VS 解决方案。所以我转向下一个提示——“有效的 Configuration 和 Platform 组合”。
哦!Visual Studio 正在尝试构建 “Configuration='Debug', Platform='x64'” 。查看我的项目文件后,我意识到 x64 没有列在可能的平台之一。换句话说,我有以下条目(缩短):
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Debug\</OutputPath>
. . .
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
. . .
</PropertyGroup>
很简单的解决方法:只需要添加x64项!
我复制/粘贴了x86的条目,并将它们改为使用x64。请注意,我还修改了路径,以避免覆盖x86版本:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Debug\</OutputPath>
. . .
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
. . .
</PropertyGroup>