我将一个项目从 VS 2005 更新到 VS 2010 并收到相同的错误消息。
“项目元数据“%(Filename)”不能应用于路径“obj\Debug|x86\Debug\DemoCSharp.pdb”。路径中有非法字符。”问题是 Visual Studio 2010 无法将 csproj 文件转换为新格式,但它并没有告诉我们错误的确切位置。
在我的 VS 2005 csproj 文件中有以下 XML 代码:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">Debug|x86</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{05F88317-0CA7-4FE5-8520-35422402941A}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>DemoCSharp</RootNamespace>
<AssemblyName>DemoCSharp</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\output32\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>..\output32\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\output64\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>..\output64\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
Visual Studio 不会告诉我们是哪一行产生了问题。但我是通过“试错”找到的。
错误消息的原因显然是Visual Studio 转换向导中的错误,因为 VS 2005 加载此 csproj 文件没有问题,而 VS 2010 无法转换它。
所以你必须手动编辑和修复这个文件,然后在 VS2010 中重新加载它。
在我的情况下,触发错误的行是带有<Platform Condition 的 3. 行。错误是 VS 尝试获取此平台条件 XML 节点的 value ("Debug|x86") 并将其嵌入到磁盘上的路径中(如 "...\obj\Debug|x86 \...”)。但由于管道字符在路径中是非法的,它随后会抱怨并中止转换。
那么如何解决这个问题呢?
我只是替换了第三行
<Platform Condition=" '$(Platform)' == '' ">Debug|x86</Platform>
与
<Platform Condition=" '$(Platform)' == '' ">Debug</Platform>
这消除了管道字符和项目转换没有错误。
注意:也可以完全删除这一行。
注意:
在您的情况下,与我的情况相比,相同的错误消息可能需要另一个修复。请研究 csproj 文件并查找管道字符,然后通过尝试和错误找出如何修改它。此错误甚至可能出现在转换项目以外的其他条件下。
但它们的共同点是,这是一个试图将管道字符嵌入到路径中的 Visual Studio 错误(或者在“littlechris”的情况下是一个软件扩展错误)。
XML node: "Debug|x86" -> path "...\obj\Debug|x86\..."