- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
重现步骤:
.NET 4.6.1
. Newtonsoft.Json
的引用使用 Nuget 包管理器。 VS2017
成功构建项目. dotnet build
从项目目录。 error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>
<ProjectGuid>{42A41D81-0A26-4D79-935E-6002BFAD37EB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClassLibrary1</RootNamespace>
<AssemblyName>ClassLibrary1</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</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>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>9.0.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace ClassLibrary1
{
public class Class1
{
[JsonProperty]
public string asd { get; set; }
}
}
最佳答案
您正在使用“旧式”msbuild 项目,该项目不适用于 dotnet
命令行界面。
将整个项目文件替换为:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
</Project>
dotnet
兼容CLI,一切都应该很好。
关于c# - Dotnet 构建不适用于 newcsproj 和 PackageReference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45036260/
Nuget.Config 中是否有任何方法可以将包管理选项默认为“PackageReference”?我将假设没有,因为我没有看到它 here但我想我会问。 我希望在某个存储库的所有开发人员机器上默认
我正在尝试使用 Directory.Builds.props/Directory.Build.targets 文件来集中我们的一些项目配置。不幸的是,我们混合了新旧(sdk 样式)项目格式。由于新格式
在我的 VS 2017 项目中,我引用了 docfx.console 包,我希望它仅在满足特定条件时使用。但是该包被用于所有构建。 这是我项目的一部分。我希望在配置为 Installer/AnyCPU
背景 我正在处理一个包含多个大型解决方案的大型项目。总而言之,我们有超过 400 个 C# 项目。过去我们使用 Nuget 和 packages.config我们的依赖文件。现在我们要将所有项目迁移到
我正在清理一个项目,该项目已经经历了大部分开发周期并且几乎准备好投入生产。我想删除 csproj 中任何不需要的 PackageReference,但似乎找不到任何方法来检测它们,除了可能单独删除每个
我的 NetStandard 项目中有以下内容 当我将其更改为使用通配符(而不是 1.0.1)时,我在依赖项切换上得到一个感叹号,然后是 NuGet 切换,当然还有包本身。 当我 checkin
我们有一堆快速移动的内部 nuget 包。 我们希望这些软件包的使用者始终使用最新版本。目前,我们通过在构建之前在命令行上运行 nuget update 在 CI 系统上执行此操作。 但是我们现在正在
我正在尝试通过 Jenkins Pipeline 运行以下命令 bat 'nuget restore mySolution.sln -MSBuildPath "C:\\Program Files (x
让我们考虑一下这样的场景:我们有两个 .NET Standard 项目,我们想要为其公开并创建 NuGet 包: 图书馆解决方案 类库1 (CL1) ∟类库2(CL2) 值得一提的是,CL1 有一个对
将 WindowsRuntime 添加到 WinForms 项目后,构建项目失败,并出现错误“必须使用 PackageReference”。构建日志更加精确: C:[...]\Visual Studi
我有许多针对 .net 4.6.1 的项目的解决方案。在我们的 MS 构建服务器上,它构建得很好。我最近添加了一个针对 .NET Standard 1.3 的项目。这不会在构建服务器上构建。它在本地使
我正在使用 Microsoft Visual Studio Community 2022(64 位)- 预览版 17.3.0 预览版 1.1。 错误 Severity Code Descr
发布 Nuget 包时指定 PackageReference 的最佳做法是什么? 根据 https://learn.microsoft.com/en-us/nuget/consume-packages
重现步骤: 打开Visual Studio 2017,新建类库项目,.NET 4.6.1 . 添加对 Newtonsoft.Json 的引用使用 Nuget 包管理器。 使用 VS2017 成功构建项
我创建了一个 Directory.Build.props通过右键单击“解决方案资源管理器”上的“解决方案”,创建一个 XML 文件并为其命名。然后我输入此 XML 并尝试构建,但遇到了错误:
我正在将旧式 MsBuild csproj 项目迁移为使用 PackageReference 格式,但遇到了传递依赖项问题。 考虑以下因素项目 A 引用 NuGet 包 B 和 C,每个包都包含一个使
我有一个带有一些 NuGet 依赖项的项目,使用 PackageReference: 我不希望依赖直接安装在bin\${buildConfiguration}\${framew
在我的项目中,我像这样使用 PackageReference 引用了一些包: 但是,如果我运行 pack 命令,它不会包含它们,除非我手动将它们添加到 .nuspec 文件中。 我想将我的 C# 项目
在 .NET 较旧的 NuGet packages.config 系统下,I could constrain the possible versions of a package在使用 allowed
ProjectA引用文献 ProjectB ProjectB引用文献 ProjectC ProjectA有PackageReference在 .csproj 鉴于以上,可以直接引用ProjectC输入
我是一名优秀的程序员,十分优秀!