如何解决NuGet.targets(124,5):错误:值不能>无效的.(参数"folderName")错误? [英] How to solve NuGet.targets(124,5): error : Value cannot be > null. (Parameter 'folderName') error?

查看:47
本文介绍了如何解决NuGet.targets(124,5):错误:值不能>无效的.(参数"folderName")错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建项目时出现此错误.

On building the project I am getting this error.

错误NETSDK1004资产文件找不到'J:\ Test \ core \ fx-core \ obj \ project.assets.json'.运行NuGet软件包还原以生成此文件.FxCore C:\程序文件\ dotnet \ sdk \ 3.1.201 \ Sdks \ Microsoft.NET.Sdk \ targets \ Microsoft.PackageDependencyResolution.targets 234

Error NETSDK1004 Assets file 'J:\Test\core\fx-core\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. FxCore C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234

因此,要解决此问题,我在程序包管理器控制台中运行命令 dotnet restore .但是在运行时,出现以下错误.

So to solve this I am running the command dotnet restore in package manager console. But on running I'm getting the below error.

PM>dotnet恢复J:\ Test \ core \ fx-core \ FxCore.csproj(3,3):警告MSB4011:" C:\ ProgramFiles \ dotnet \ sdk \ 3.1.201 \ Current \ Microsoft.Common.props不可能是再次导入.它已经在"C:\ Program"中导入文件\ dotnet \ sdk \ 3.1.201 \ Sdks \ Microsoft.NET.Sdk \ Sdk \ Sdk.props(40,3)".这很可能是构建创作错误.此后的导入将被忽略.C:\程序文件\ dotnet \ sdk \ 3.1.201 \ Sdks \ Microsoft.NET.Sdk \ Sdk \ Sdk.targets(37,3):警告MSB4011:" C:\ ProgramFiles \ dotnet \ sdk \ 3.1.201 \ Microsoft.CSharp.targets"无法导入再次.它已经在"J:\ Test \ core \ fx-core \ FxCore.csproj"中导入(118,3)".这很可能是构建创作错误.此后导入将被忽略.C:\程序Files \ dotnet \ sdk \ 3.1.201 \ NuGet.targets(124,5):错误:值不能为无效的.(参数"folderName")[J:\ Test \ core \ fx-core \ FxCore.sln] PM>

PM> dotnet restore J:\Test\core\fx-core\FxCore.csproj(3,3): warning MSB4011: "C:\Program Files\dotnet\sdk\3.1.201\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props (40,3)". This is most likely a build authoring error. This subsequent import will be ignored. C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(37,3): warning MSB4011: "C:\Program Files\dotnet\sdk\3.1.201\Microsoft.CSharp.targets" cannot be imported again. It was already imported at "J:\Test\core\fx-core\FxCore.csproj (118,3)". This is most likely a build authoring error. This subsequent import will be ignored. C:\Program Files\dotnet\sdk\3.1.201\NuGet.targets(124,5): error : Value cannot be null. (Parameter 'folderName') [J:\Test\core\fx-core\FxCore.sln] PM>

如何解决此问题?

.Net Target框架:4.6.1

.Net Target framework: 4.6.1

Visual Studio:2019(16.5.2)

Visual Studio: 2019 (16.5.2)

项目类型:类库

更新:

根据@Lennart请求添加csproj文件

Adding csproj file based on @Lennart request

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Sdk="Microsoft.NET.Sdk">
  <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>
    <ProjectGuid>{459BF9F7-69C7-4BBD-B566-CEFB992F88D5}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>FX.Core</RootNamespace>
    <AssemblyName>FxCore</AssemblyName>
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <Version>1.0.2.9</Version>
    <Company>INTL FCStone</Company>
    <Authors>INTL FCStone</Authors>
    <Description>FxCore Assembly</Description>
    <Copyright>Copyright 2018</Copyright>
    <PackageReleaseNotes>version 1.0.2</PackageReleaseNotes>
    <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>TRACE;DEBUG</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Compile Remove="packages\**" />
    <Compile Remove="_CreateNewNuGetPackage\**" />
    <EmbeddedResource Remove="packages\**" />
    <EmbeddedResource Remove="_CreateNewNuGetPackage\**" />
    <None Remove="packages\**" />
    <None Remove="_CreateNewNuGetPackage\**" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Dapper, Version=1.50.2.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\Dapper.1.50.2\lib\net45\Dapper.dll</HintPath>
    </Reference>
    <Reference Include="EasyNetQ, Version=0.63.6.463, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\EasyNetQ.0.63.6.463\lib\net45\EasyNetQ.dll</HintPath>
    </Reference>
    <Reference Include="FXEntity, Version=1.0.1.12, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\FXEntity.1.0.2.12\lib\net45\FXEntity.dll</HintPath>
    </Reference>
    <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
      <HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
      <HintPath>packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.Unity.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
      <HintPath>packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.Configuration.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.Unity.RegistrationByConvention, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
      <HintPath>packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.RegistrationByConvention.dll</HintPath>
    </Reference>
    <Reference Include="Ninject, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
      <HintPath>packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll</HintPath>
    </Reference>
    <Reference Include="RabbitMQ.Client, Version=3.6.6.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
      <HintPath>packages\RabbitMQ.Client.3.6.6\lib\net45\RabbitMQ.Client.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Web" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Properties\" />
    <Compile Remove="Configuration\UspHostLoginValidateResult.cs" />
    <Compile Remove="Configuration\UspHostUserRoleMenuListResult.cs" />
    <Compile Remove="Properties\AssemblyInfo.cs" />
    <Folder Include="DataAccess\" />
    <Folder Include="DataAccess\Components" />
    <Folder Include="Diagnostics\" />
    <Folder Include="Diagnostics\Components" />
    <Folder Include="NetworkProtocols\" />
    <Folder Include="Unity\" />   
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config">
      <SubType>Designer</SubType>
    </None>
    <None Include="packages.config" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Connect.SSO" Version="3.5.6.1" />
    <PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.6" />
    <PackageReference Include="Dapper" Version="1.50.2.0" />
    <PackageReference Include="EasyNetQ" Version="0.63.6.463" />
    <PackageReference Include="log4net" Version="2.0.8.0" />
    <PackageReference Include="Microsoft.Practices.ServiceLocation" Version="1.3.0.0" />
    <PackageReference Include="Ninject" Version="3.2.0.0" />
    <PackageReference Include="RabbitMQ.Client" Version="3.6.6.0" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!--<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;" />
  </Target>-->
</Project>

推荐答案

在csproj中,发生了一些事情:

In the csproj, a few things leap out:

  • 有两个< Import> 看起来不必要-删除/注释它们
  • 没有目标框架-试试< TargetFramework> net461</TargetFramework> 或第一个< PropertyGroup>
  • 中的类似内容
  • 根元素过于复杂;可以只是< Project Sdk ="Microsoft.NET.Sdk">
  • 对于同样具有< PackageReference> 的东西,您不需要< Reference> 元素-您可以删除< Reference> ,例如"Dapper"和"Ninject"表示
    • 如果可能的话,最好单独使用包引用
    • there's two <Import> that look unnecessary - remove/comment them
    • there's no target framework(s) - try <TargetFramework>net461</TargetFramework> or similar in the first <PropertyGroup>
    • the root element is overly complex; can be just <Project Sdk="Microsoft.NET.Sdk">
    • you don't need <Reference> elements for things that also have <PackageReference> - you can probably remove the <Reference> for things like "Dapper" and "Ninject"
      • it would be preferable to use package-references exclusively, if possible

      但是:经过这些更改,它应该可以工作.我的猜测是,这是一个SDK之前的项目文件,已被手动黑客攻击,并被调整为接近正常工作的SDK项目文件的文件.

      but: with those changes, it should work. My guess is that this was a pre-SDK project file that has been manually hacked and tweaked into something close to a working SDK project file.

      <?xml version="1.0" encoding="utf-8"?>
      <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
        <TargetFramework>net461</TargetFramework>
          <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
          <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
          <ProjectGuid>{459BF9F7-69C7-4BBD-B566-CEFB992F88D5}</ProjectGuid>
          <OutputType>Library</OutputType>
          <AppDesignerFolder>Properties</AppDesignerFolder>
          <RootNamespace>FX.Core</RootNamespace>
          <AssemblyName>FxCore</AssemblyName>
          <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
          <FileAlignment>512</FileAlignment>
          <TargetFrameworkProfile />
          <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
          <Version>1.0.2.9</Version>
          <Company>INTL FCStone</Company>
          <Authors>INTL FCStone</Authors>
          <Description>FxCore Assembly</Description>
          <Copyright>Copyright 2018</Copyright>
          <PackageReleaseNotes>version 1.0.2</PackageReleaseNotes>
          <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
          <DebugSymbols>true</DebugSymbols>
          <DebugType>full</DebugType>
          <Optimize>false</Optimize>
          <OutputPath>bin\Debug\</OutputPath>
          <DefineConstants>TRACE;DEBUG</DefineConstants>
          <ErrorReport>prompt</ErrorReport>
          <WarningLevel>4</WarningLevel>
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
          <DebugType>pdbonly</DebugType>
          <Optimize>true</Optimize>
          <OutputPath>bin\Release\</OutputPath>
          <DefineConstants>TRACE</DefineConstants>
          <ErrorReport>prompt</ErrorReport>
          <WarningLevel>4</WarningLevel>
        </PropertyGroup>
        <ItemGroup>
          <Compile Remove="packages\**" />
          <Compile Remove="_CreateNewNuGetPackage\**" />
          <EmbeddedResource Remove="packages\**" />
          <EmbeddedResource Remove="_CreateNewNuGetPackage\**" />
          <None Remove="packages\**" />
          <None Remove="_CreateNewNuGetPackage\**" />
        </ItemGroup>
        <ItemGroup>
          <Reference Include="FXEntity, Version=1.0.1.12, Culture=neutral, processorArchitecture=MSIL">
            <HintPath>packages\FXEntity.1.0.2.12\lib\net45\FXEntity.dll</HintPath>
          </Reference>
          <Reference Include="Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
            <HintPath>packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.dll</HintPath>
          </Reference>
          <Reference Include="Microsoft.Practices.Unity.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
            <HintPath>packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.Configuration.dll</HintPath>
          </Reference>
          <Reference Include="Microsoft.Practices.Unity.RegistrationByConvention, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
            <HintPath>packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.RegistrationByConvention.dll</HintPath>
          </Reference>
          <Reference Include="System" />
          <Reference Include="System.configuration" />
          <Reference Include="System.Core" />
          <Reference Include="System.Web" />
          <Reference Include="System.Xml.Linq" />
          <Reference Include="Microsoft.CSharp" />
          <Reference Include="System.Data" />
          <Reference Include="System.Net.Http" />
          <Reference Include="System.Xml" />
        </ItemGroup>
        <ItemGroup>
          <Folder Include="Properties\" />
          <Compile Remove="Configuration\UspHostLoginValidateResult.cs" />
          <Compile Remove="Configuration\UspHostUserRoleMenuListResult.cs" />
          <Compile Remove="Properties\AssemblyInfo.cs" />
          <Folder Include="DataAccess\" />
          <Folder Include="DataAccess\Components" />
          <Folder Include="Diagnostics\" />
          <Folder Include="Diagnostics\Components" />
          <Folder Include="NetworkProtocols\" />
          <Folder Include="Unity\" />   
        </ItemGroup>
        <ItemGroup>
          <None Include="app.config">
            <SubType>Designer</SubType>
          </None>
          <None Include="packages.config" />
        </ItemGroup> 
        <ItemGroup>
          <PackageReference Include="Connect.SSO" Version="3.5.6.1" />
          <PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.6" />
          <PackageReference Include="Dapper" Version="1.50.2.0" />
          <PackageReference Include="EasyNetQ" Version="0.63.6.463" />
          <PackageReference Include="log4net" Version="2.0.8.0" />
          <PackageReference Include="Microsoft.Practices.ServiceLocation" Version="1.3.0.0" />
          <PackageReference Include="Ninject" Version="3.2.0.0" />
          <PackageReference Include="RabbitMQ.Client" Version="3.6.6.0" />
        </ItemGroup>
      </Project>
      

      这篇关于如何解决NuGet.targets(124,5):错误:值不能&gt;无效的.(参数"folderName")错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆