使用 Visual Studio 2019 打开时项目被卸载
Project gets unloaded when opening with Visual Studio 2019
我正在尝试使用 Visual studio 2019 和 visual studio 2017 打开一个解决方案。解决方案中的所有项目都在加载,一个除外。尝试加载卸载的项目时,我在输出 window as
中收到错误
TakstMVC.csproj : error : The imported project
"....build\MSBuild.Community.Tasks.targets" was not found. Confirm
that the expression in the Import declaration
"TakstMVC\.....build\MSBuild.Community.Tasks.targets" is correct,
and that the file exists on disk. TakstMVC\FluentMigrator.targets
当我尝试使用 VS 2017 打开时,我看到一份迁移报告说
TakstMVC.csproj: The application which this project type is based on
was not found. Please try this link for further information:
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>
我的电脑安装了以下软件
- Microsoft .NET Framework 4.7.1 SDK
- Microsoft .NET Framework 4.7.1 SDK 目标包(ENU)
- Microsoft .NET Core 3.1.1 - Windows 服务器托管
- 微软 .NET 核心 SDK 3.1.101 (x64)
- 微软 .NET 核心 SDK 2.2.207 (x64)
- Microsoft .NET Core 运行时 - 3.1.1
- Microsoft .NET Core 运行时 - 2.2.8
我尝试安装 dotnetfx35.exe,但它在执行时甚至 运行 都没有(甚至没有消息或错误)。
windows 功能如下:
如何识别项目的目标框架并成功加载到visual studio?感谢对此的一些建议。
错误很明显,您没有在本地正确导入MSBuild.Community.Tasks.targets
。原因是您没有在电脑上安装MSBuild.Community.Tasks.targets
或者csproj
文件的导入路径不正确。
您应该check this document安装正确的目标。
首先,删除 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>
然后,在csproj文件下添加这些:
<Import Project="C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
除了,你也可以使用nuget函数。首先,如果项目中有旧版本,请卸载 nuget 包。然后,使用第一个建议删除任何先前的 import projects="xxx\MSBuildTasks.targets"
。之后,安装 MSBuildTasks nuget package。那是一样的。
更新
试试你应该把..\..\
改成..\
。使用正确的路径。
或在工具下使用此命令-->Nuget包管理器--> 包管理器控制台
update-package -reinstall
客户的回答
令人尴尬的是,整个问题都与我的解决方案位于本地计算机的解决方案路径有关。我有很长的路要走,包括一个也有两个词的文件夹。在尝试了所有其他方法后,我将解决方案文件夹移至 C:\temp 文件夹,问题不再存在。 VS 中显示的错误具有误导性。真是浪费时间。感谢您的努力!
我正在尝试使用 Visual studio 2019 和 visual studio 2017 打开一个解决方案。解决方案中的所有项目都在加载,一个除外。尝试加载卸载的项目时,我在输出 window as
中收到错误TakstMVC.csproj : error : The imported project "....build\MSBuild.Community.Tasks.targets" was not found. Confirm that the expression in the Import declaration "TakstMVC\.....build\MSBuild.Community.Tasks.targets" is correct, and that the file exists on disk. TakstMVC\FluentMigrator.targets
当我尝试使用 VS 2017 打开时,我看到一份迁移报告说
TakstMVC.csproj: The application which this project type is based on was not found. Please try this link for further information: 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>
我的电脑安装了以下软件
- Microsoft .NET Framework 4.7.1 SDK
- Microsoft .NET Framework 4.7.1 SDK 目标包(ENU)
- Microsoft .NET Core 3.1.1 - Windows 服务器托管
- 微软 .NET 核心 SDK 3.1.101 (x64)
- 微软 .NET 核心 SDK 2.2.207 (x64)
- Microsoft .NET Core 运行时 - 3.1.1
- Microsoft .NET Core 运行时 - 2.2.8
我尝试安装 dotnetfx35.exe,但它在执行时甚至 运行 都没有(甚至没有消息或错误)。
windows 功能如下:
如何识别项目的目标框架并成功加载到visual studio?感谢对此的一些建议。
错误很明显,您没有在本地正确导入MSBuild.Community.Tasks.targets
。原因是您没有在电脑上安装MSBuild.Community.Tasks.targets
或者csproj
文件的导入路径不正确。
您应该check this document安装正确的目标。
首先,删除 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>
然后,在csproj文件下添加这些:
<Import Project="C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
除了,你也可以使用nuget函数。首先,如果项目中有旧版本,请卸载 nuget 包。然后,使用第一个建议删除任何先前的 import projects="xxx\MSBuildTasks.targets"
。之后,安装 MSBuildTasks nuget package。那是一样的。
更新
试试你应该把..\..\
改成..\
。使用正确的路径。
或在工具下使用此命令-->Nuget包管理器--> 包管理器控制台
update-package -reinstall
客户的回答
令人尴尬的是,整个问题都与我的解决方案位于本地计算机的解决方案路径有关。我有很长的路要走,包括一个也有两个词的文件夹。在尝试了所有其他方法后,我将解决方案文件夹移至 C:\temp 文件夹,问题不再存在。 VS 中显示的错误具有误导性。真是浪费时间。感谢您的努力!