我正在尝试使用 Visual Studio 2019 和 Visual Studio 2017 打开一个解决方案。解决方案中的所有项目都在加载,只有一个项目除外。当尝试加载已卸载的项目时,我在输出窗口中收到错误消息:
TakstMVC.csproj:错误:导入的项目 找不到“....build\MSBuild.Community.Tasks.targets”。确认 导入声明中的表达式 “TakstMVC\.....build\MSBuild.Community.Tasks.targets”是正确的, 并且该文件存在于磁盘上。 TakstMVC\FluentMigrator.targets
当我尝试使用 VS 2017 打开时,我看到了一份迁移报告,上面写着
TakstMVC.csproj:该项目类型所基于的应用程序 没找到。请尝试此链接以获取更多信息: http://go.microsoft.com/fwlink/?LinkID=299083&projecttype=E3E379DF-F4C6-4180-9B81-6769533ABE47
项目.csproj的部分内容如下:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A4354F5C-ECF5-4621-AA9E-B91FE543F096}</ProjectGuid>
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TakstMVC</RootNamespace>
<AssemblyName>TakstMVC</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<UseIISExpress>true</UseIISExpress>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
我的电脑中安装了以下软件
我尝试安装 dotnetfx35.exe,但执行时它甚至不运行(甚至没有消息或错误)。 windows功能如下:
如何识别项目的目标框架并成功加载到Visual Studio中?感谢对此的一些建议。
错误很明显是您没有在本地正确导入
MSBuild.Community.Tasks.targets
。原因是您的电脑上没有安装MSBuild.Community.Tasks.targets
或者csproj
文件的导入路径不正确。
您应该检查此文档以安装正确的目标。
首先,删除
csproj
文件下的xml节点,如下所示:
<Import Project="..\build\MSBuild.Community.Tasks.targets" Condition="Exists('..\build\MSBuild.Community.Tasks.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\build\MSBuild.Community.Tasks.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\build\MSBuild.Community.Tasks.targets'))" />
</Target>
第二,安装msi文件。
然后,在 csproj 文件下添加这些:
<Import Project="C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
除了,你还可以使用nuget函数。首先,如果项目上有旧版本,请卸载 nuget 包。然后,使用第一个建议删除之前的所有
import projects="xxx\MSBuildTasks.targets"
。之后,安装MSBuildTasks nuget包。那是一样的。
更新
尝试您应该将
..\..\
更改为 ..\
。使用正确的路径。
或者在Tools-->Nuget Package Manager-->Package Manager Console
下使用此命令update-package -reinstall
令人尴尬的是,整个问题在于我的解决方案位于本地计算机中的解决方案路径。我有一条很长的路径,包括一个也有两个单词的文件夹。在尝试了其他所有方法后,我将解决方案文件夹移动到 C: emp 文件夹,问题不再存在。 VS 中显示的错误非常具有误导性。多么浪费时间啊。谢谢你们的努力!
尝试删除项目下的
*.vcxproj.user
文件,然后右键项目->重新加载项目(你会发现又会生成*.vcxproj.user
文件)