无法读取项目文件 .csproj,请确认<Import> 声明中的路径正确,且磁盘上存在该文件。
找了相关的错误,找不到原因,其他的项目文件都加载进去,但不知为什么这个加载不进去。
我就查看了一下其他项目的.csproj的文件,与发生错误的.csproj 文件核对下,把其中<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ImportProject="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplicati ons\Microsoft.WebApplication.targets" />改为:<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /><ImportProject="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\WebApplicati ons\Microsoft.WebApplication.targets" Condition="'$(Solutions.VSVersion)' == '8.0'" /><ImportProject="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplicati ons\Microsoft.WebApplication.targets" Condition="'$(Solutions.VSVersion)' == '9.0'" />都可以加载进去项目文件了!这个一般在网上下载的项目,或者朋友给的项目总出这样问题,开始一直都没解决,今天不知道怎么来灵感了。
去对照了一下各自的.csproj文件中的<Import>节点的配置!结果还真给解决了问题,不错。
呵呵高兴!以下方法是我在网上搜的,我用的是vs2008版本!估计是他是用的vs2005版本的。
大家经常会非常辛苦的在网上找到自己想要的源程序,在我们欣喜若狂打开的时候,却提示“未找到导入的项目“$:\Boo.Microsoft.Build.targets”。
请确认<Import> 声明中的路径正确,且磁盘上存在该文件。
解决办法:将项目文件(.csproj)用记事本打开,然后找到<Import >节点,作如下操作:<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />替换为:<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 这个才是最终的解决方案!!!或者直接将下述文本复制到记事本,另存为“Microsoft.CSharp.targets”,放到项目所在盘符的根目录下,一键OK.复制内容如下:<!--******************************************************************************* ****************Microsoft.CSharp.targetsWARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and havecreated a backup copy. Incorrect changes to this file will make itimpossible to load or build your projects from the command-line or the IDE.This file defines the steps in the standard build process specific for C# .NET projects.For example, it contains the step that actually calls the C# compiler. The remainderof the build process is defined in mon.targets, which is imported bythis file.Copyright (C) Microsoft Corporation. All rights reserved.******************************************************************************* ****************--><Project xmlns="/developer/msbuild/2003"><UsingTask TaskName="CreateCSharpManifestResourceName" AssemblyName="Microsoft.Build.Tasks, V ersion=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/><PropertyGroup><MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildBinPath)\Microsoft.CSharp.targets</M SBuildAllProjects><DefaultLanguageSourceExtension>.cs</DefaultLanguageSourceExtension><Language>C#</Language></PropertyGroup><!--The CreateManifestResourceNames target create the manifest resource names from the .RESXfiles.[IN]@(ResxWithNoCulture) - The names the non-culture .RESX files.@(ResxWithCulture) - The names the culture .RESX files.@(NonResxWithNoCulture) - The names of the non-culture non-RESX files (like bitmaps, etc).@(NonResxWithCulture) - The names of the culture non-RESX files (like bitmaps, etc).[OUT]@(ManifestResourceWithNoCultureName) - The corresponding manifest resource name (.RESOURCE)@(ManifestResourceWithCultureName) - The corresponding manifest resource name (.RESOURCE)@(ManifestNonResxWithNoCulture) - The corresponding manifest resource name.@(ManifestNonResxWithCulture) - The corresponding manifest resource name.For C# applications the transformation is like:Resources1.resx => RootNamespace.Resources1 => Build into main assemblySubFolder\Resources1.resx => RootNamespace.SubFolder.Resources1 => Build into main assemblyResources1.fr.resx => RootNamespace.Resources1.fr => Build into satellite assemblyResources1.notaculture.resx => RootNamespace.Resources1.notaculture => Build into main assemblyFor other project systems, this transformation may be different.--><PropertyGroup><CreateManifestResourceNamesDependsOn></CreateManifestResourceNamesDependsOn> </PropertyGroup><TargetName="CreateManifestResourceNames"Condition="'@(ResxWithNoCulture)@(ResxWithCulture)@(NonResxWithNoCulture)@(NonRes xWithCulture)'!=''"DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"><!-- Create the target resource names for non-culture resx files. --><CreateCSharpManifestResourceName Condition="'@(ResxWithNoCulture)'!=''"ResourceFiles="@(ResxWithNoCulture)"RootNamespace="$(RootNamespace)"><Output TaskParameter="ManifestResourceNames" ItemName="ManifestResourceWithNoCultureName"/></CreateCSharpManifestResourceName><!-- Create the target resource names for culture resx files. --><CreateCSharpManifestResourceName Condition="'@(ResxWithCulture)'!=''"ResourceFiles="@(ResxWithCulture)"RootNamespace="$(RootNamespace)"><Output TaskParameter="ManifestResourceNames" ItemName="ManifestResourceWithCultureName"/></CreateCSharpManifestResourceName><!-- Create the target resource names for non-culture non-resx files. --><CreateCSharpManifestResourceName Condition="'@(NonResxWithNoCulture)'!=''"ResourceFiles="@(NonResxWithNoCulture)"RootNamespace="$(RootNamespace)"><Output TaskParameter="ManifestResourceNames" ItemName="ManifestNonResxWithNoCulture"/></CreateCSharpManifestResourceName><!-- Create the target resource names for culture non-resx files. --><CreateCSharpManifestResourceName Condition="'@(NonResxWithCulture)'!=''"ResourceFiles="@(NonResxWithCulture)"RootNamespace="$(RootNamespace)"><Output TaskParameter="ManifestResourceNames" ItemName="ManifestNonResxWithCulture"/></CreateCSharpManifestResourceName></Target><PropertyGroup><!-- "None" is not technically a valid DebugType, so we can't pass it in as suchto the compiler. So here, we modify the properties so they make sense. --> <DebugSymbols Condition=" '$(DebugType)' == 'none' ">false</DebugSymbols><DebugType Condition=" '$(DebugType)' == 'none' "></DebugType><_DisabledWarnings>$(NoWarn)</_DisabledWarnings><!-- Provide a facility to override UseHostCompilerIfA vailable--><UseHostCompilerIfA vailable Condition=" '$(UseHostCompilerIfA vailable)' == ''">true</UseHostCompilerIfA vailable></PropertyGroup><!-- These two compiler warnings are raised when a reference is bound to a different version than specified in the assembly reference version number. MSBuild raises the same warning in this case,so the compiler warning would be redundant. --><PropertyGroup Condition="('$(TargetFrameworkV ersion)' != 'v1.0') and ('$(TargetFrameworkV ersion)' != 'v1.1')"><_DisabledWarnings Condition="'$(_DisabledWarnings)' != ''">$(_DisabledWarnings);</_DisabledWarnings><_DisabledWarnings>$(_DisabledWarnings)1701;1702</_DisabledWarnings> </PropertyGroup><ItemGroup><DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/></ItemGroup><PropertyGroup><CoreCompileDependsOn>_ComputeNonExistentFileProperty</CoreCompileDependsOn> </PropertyGroup><TargetName="CoreCompile"Inputs="$(MSBuildAllProjects);@(Compile);@(ManifestResourceWithNoCulture);$(ApplicationIcon);$(AssemblyOriginatorKeyFile);@(ManifestNonResxWithNoCultureOnDisk);@(ReferencePath);@(CompiledLicenseFile);@(EmbeddedDocumentation);@(CustomAdditionalCompileInputs)"Outputs="@(DocFileItem);@(IntermediateAssembly);$(NonExistentFile);@(CustomAdditionalCompileOutputs)"DependsOnTargets="$(CoreCompileDependsOn)"><CscAdditionalLibPaths="$(AdditionalLibPaths)"AddModules="@(AddModules)"AllowUnsafeBlocks="$(AllowUnsafeBlocks)"BaseAddress="$(BaseAddress)"CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"CodePage="$(CodePage)"DebugType="$(DebugType)"DefineConstants="$(DefineConstants)"DelaySign="$(DelaySign)"DisabledWarnings="$(_DisabledWarnings)"DocumentationFile="@(DocFileItem)"EmitDebugInformation="$(DebugSymbols)"ErrorReport="$(ErrorReport)"FileAlignment="$(FileAlignment)"GenerateFullPaths="$(GenerateFullPaths)"KeyContainer="$(KeyContainerName)"KeyFile="$(KeyOriginatorFile)"LangV ersion="$(LangV ersion)"MainEntryPoint="$(StartupObject)"ModuleAssemblyName="$(ModuleAssemblyName)"NoConfig="true"NoLogo="$(NoLogo)"NoStandardLib="$(NoStdLib)"Optimize="$(Optimize)"OutputAssembly="@(IntermediateAssembly)"PdbFile="$(PdbFile)"Platform="$(PlatformTarget)"References="@(ReferencePath)"Resources="@(ManifestResourceWithNoCulture);@(ManifestNonResxWithNoCultureOnDisk); @(CompiledLicenseFile)"ResponseFiles="$(CompilerResponseFile)"Sources="@(Compile)"TargetType="$(OutputType)"ToolPath="$(CscToolPath)"TreatWarningsAsErrors="$(TreatWarningsAsErrors)"UseHostCompilerIfA vailable="$(UseHostCompilerIfA vailable)"Utf8Output="$(Utf8Output)"WarningLevel="$(WarningLevel)"WarningsAsErrors="$(WarningsAsErrors)"WarningsNotAsErrors="$(WarningsNotAsErrors)"Win32Icon="$(ApplicationIcon)"Win32Resource="$(Win32Resource)"/></Target><Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /></Project>。