【发布时间】:2019-07-05 21:13:06
【问题描述】:
我刚刚浏览了解决方案中的每个项目,并从 .NET Framework 4.6.1 => 4.7.2 升级,只有一个项目无法加载。当我尝试重新加载项目时,它会抛出此错误:
3:07 PM Project 'MyProject' load finished with warnings: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. at (1:1)
3:07 PM Project 'MyProjectEmailService' load failed: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. C:\Projects\Repo\Source\MyProject\MyProjectEmailService\MyProjectEmailService.csproj at (1:1)
3:07 PM Project 'MyProjectEmailService.Tests' load finished with warnings: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. at (1:1)
3:07 PM Project 'MyProjectEmailService.Tests' load finished with warnings: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. at (1:1)
3:08 PM Project 'MyProjectEmailService' load failed: The project file could not be loaded. The 'Project' start tag on line 2 position 2 does not match the end tag of 'Target'. Line 281, position 5. C:\Projects\Repo\Source\MyProject\MyProjectEmailService\MyProjectEmailService.csproj at (281:5)
3:09 PM Project 'MyProjectEmailService' load failed: The project file could not be loaded. The 'Project' start tag on line 2 position 2 does not match the end tag of 'Target'. Line 281, position 5. C:\Projects\Repo\Source\MyProject\MyProjectEmailService\MyProjectEmailService.csproj at (281:5)
据我所知,MyProjectEmailService.csproj 中的第 281 行似乎有问题
在第 281 行,我找到了</target>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<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('..\..\packages\OctoPack.3.6.1\build\OctoPack.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\OctoPack.3.6.1\build\OctoPack.targets'))" />
<Error Condition="!Exists('..\..\packages\Selenium.Firefox.WebDriver.0.23.0\build\Selenium.Firefox.WebDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Selenium.Firefox.WebDriver.0.23.0\build\Selenium.Firefox.WebDriver.targets'))" />
<Error Condition="!Exists('..\..\packages\Selenium.WebDriver.GeckoDriver.0.24.0\build\Selenium.WebDriver.GeckoDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Selenium.WebDriver.GeckoDriver.0.24.0\build\Selenium.WebDriver.GeckoDriver.targets'))" />
</Target>
<Import Project="..\..\packages\OctoPack.3.6.1\build\OctoPack.targets" Condition="Exists('..\..\packages\OctoPack.3.6.1\build\OctoPack.targets')" />
<Import Project="..\..\packages\Selenium.Firefox.WebDriver.0.23.0\build\Selenium.Firefox.WebDriver.targets" Condition="Exists('..\..\packages\Selenium.Firefox.WebDriver.0.23.0\build\Selenium.Firefox.WebDriver.targets')" />
<Import Project="..\..\packages\Selenium.WebDriver.GeckoDriver.0.24.0\build\Selenium.WebDriver.GeckoDriver.targets" Condition="Exists('..\..\packages\Selenium.WebDriver.GeckoDriver.0.24.0\build\Selenium.WebDriver.GeckoDriver.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
这是csproj 文件的第一行
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.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>
如何解决这个问题并让我的项目正确加载?另外,如果您需要更多信息,请告诉我。
【问题讨论】:
-
似乎你有不必要的 。检查这些标签的打开和关闭
-
"根级别的数据无效。第 1 行,位置 1" 表示文件的最开头。请出示那部分。文件后面的错误,尤其是缺少/预期的结束标记,可能是由文件开头的错误引起的。有些东西被破坏了。您是否有可以比较更改的备份(阅读:源代码控制)?
-
@madreflection 我添加了前几行
-
@madreflection 我确实可以访问源代码控制。我想知道它是否缺少启动文件的那个奇怪的 UNICODE 字符
-
物料清单。不过,这不应该是必要的。您在 XML 声明中有
encoding="utf-8"。这应该足以检测 XML 文件的编码。
标签: c# visual-studio upgrade .net-framework-version