我浏览了一些网站,发现.NET Core正在使用.NET CLI(.NET命令行界面).我使用.NET CLI创建了一个控制台应用程序,它运行正常
但是当我使用Yeoman创建一个ASP.NET Core Web应用程序并运行命令"dotnet restore"时,我收到以下错误:
Microsoft.CodeAnalysis.CSharp 1.1.0-rc1-20151109-01与DNXCore不兼容,版本= v5.0.
我也试过了
dotnet restore -s https://api.nuget.org/v3/index.json
但得到同样的错误.
如果我运行"dnu restore"然后它运行正常所以我的问题是我可以使用.NET CLI进行Web应用程序,还是仅限于控制台应用程序?
我已经通过了链接
https://github.com/dotnet/cli&http://dotnet.github.io/getting-started/
但是没有找到它支持ASP.NET Core web app的任何细节?
运行时,dotnet build我会多次收到此警告:
C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CrossTargeting.targets(145,3):
warning MSB4011: "*.fsproj.proj-info.targets" cannot be imported again.
It was already imported at "Microsoft.Common.targets (127,3)".
This is most likely a build authoring error.
This subsequent import will be ignored.
[*.fsproj]
Run Code Online (Sandbox Code Playgroud)
如何防止显示这些警告?
我有一些资源需要嵌入到 DLL 中。如果我使用 Visual Studio,我可以使用 UI 添加它们。这会将以下内容添加到csproj文件中:
<EmbeddedResource Include="Mocks\MyMock.GetDimensions().json" />
dotnet不,我喜欢使用终端命令添加资源。我该怎么办?
我正在 PowerShell 中(重新)生成一些文件,并且需要将这些文件嵌入到 DLL 中,以便我的代码可以访问它。
我创建了一个小项目,并添加了StyleCop.Analyzers包(基于Roslyn)。当我在Visual Studio中构建时,可以看到一些警告,这正是我所期望的。
但是,当我使用dotnet CLI(dotnet build)构建它时,没有收到警告。可以肯定的是,我也尝试使用msbuild,它也没有产生任何警告:
因此,我想知道:两种方法有什么区别,如何获得相同的结果?
我正在尝试创建一个dotnet新模板的NuGet包。我创建了一个nuspec文件来设置软件包的详细信息,它位于我的内容文件夹旁边,其中包含我想要打包的所有内容:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- The identifier that must be unique within the hosting gallery -->
<id>My.EpiserverCMS</id>
<!-- The package version number that is used when resolving dependencies -->
<version>1.0.0</version>
<!-- Authors contain text that appears directly on the gallery -->
<authors>Me</authors>
<description></description>
<!--
Owners are typically nuget.org identities that allow gallery
users to easily find other packages by the same owners.
-->
<owners>me</owners>
<!-- License and project URLs provide links for the gallery -->
<licenseUrl></licenseUrl> …Run Code Online (Sandbox Code Playgroud) 我使用dotnet CLI命令dotnet new classlib -o ProjectName创建了一个类库,并使用添加了EF Core Package,dotnet add package但是当我尝试运行某些dotnet ef命令时,抛出了以下错误。
后来,我意识到可以dotnet new classlib创建classlib(.netstandard)而不是创建classlib(core)。我想知道,反正是有创建CLASSLIB(核心)使用的dotnet CLI或任何替代CLASSLIB(核心)。
c# class-library projects-and-solutions .net-core dotnet-cli
我正在尝试在.net核心api应用程序中复制Visual Studio在F5调试上所做的工作。
似乎“ dotnet run --project”是我正在寻找的窍门,除了一件事:
当我使用F5运行时,它在https上运行,并且是受信任的。当我使用dotnet run运行时,它在https上运行,并且不受信任。
而且我似乎在使用该应用程序时遇到问题,即使它正在运行。
有什么想法吗?我想做与F5一样的技巧来测试我的应用程序,但是dotnet run必须缺少某种证书或其他东西吗?
我真的不想再更改源代码或对证书做任何事情,因为它按F5的设计工作,只需要为dotnet运行做同样的事情即可。
我有几个使用连接字符串的集成测试。该测试是从 azure devops 管道运行的,具有 yaml 定义(DotNetCoreCLI@2 任务)
这个 connstrings 曾经在 .runsettings 文件中设置,但我希望它们是秘密的,所以我将 conn 字符串移动到管道库,并标记为秘密。
同时,我已从运行设置文件中删除了机密,将参数值保留为空字符串。
所以现在,我只需在运行 dotnet test 时覆盖测试运行参数值...
通过阅读Microsoft的文档,我已经验证我可以在 Powershell 中完成此操作
dotnet test path\to\mytest.dll --logger trx --settings path\to\my.runsettings --% -- TestRunParameters.Parameter(name=\"Customer1.TestConnStr\", value=\"Id=xxx;Pass=yyy\") TestRunParameters.Parameter(name=\"Customer2.TestConnStr\", value=\"Id=xxx;Pass=yyy\")
Run Code Online (Sandbox Code Playgroud)
我还发现从 cmd 运行时不使用 --%,我认为这更适合我的 yaml 管道(在 Windows 代理上运行)。但是,我仍然无法在我的 yaml 任务中表达上述内容。我做了很多猜测,一个例子在这里:
- ${{ each project in parameters.projects }}:
- task: DotNetCoreCLI@2
displayName: Execute ${{ project }} integration tests
condition: succeededOrFailed()
inputs:
command: 'test'
projects: '$(Pipeline.Workspace)/IntegrationTests/*/*${{ project }}.Test.dll'
arguments: '--settings ${{ parameters.testRunSettingsFile }} -- TestRunParameters.Parameter(name=\"Customer1.TestConnStr\", value=\"${{ …Run Code Online (Sandbox Code Playgroud) 我正在使用.net核心构建API,我在发布期间遇到了这个问题:
The project being published does not support the runtime 'dnx-clr-win-x86.1.0.0-rc2-20221'
Run Code Online (Sandbox Code Playgroud)
我看到了这个问题的GitHub以及这一个,我没有接近的解决方案.这是我的更新 project.json文件:
{
"compilationOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"dependencies": {
"AspNet.Security.OAuth.Validation": "1.0.0-alpha1-*",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-*",
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-rc2-*",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-*",
"Microsoft.AspNetCore.Hosting": "1.0.0-rc2-*",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-*",
"Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-rc2-*",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-*",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-*",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-*",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-*",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-*",
"OpenIddict.Core": "1.0.0-*",
"OpenIddict.EF": "1.0.0-*"
},
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.ComponentModel": { "type": "build" }
}
},
"netcoreapp1.0": {
"dependencies": …Run Code Online (Sandbox Code Playgroud) 下面的例子,从这里我想执行
dotnet sln AllProjects.sln add **/*.csproj
Run Code Online (Sandbox Code Playgroud)
但是我得到这个错误:
找不到项目或目录
**/*.csproj。
看起来通配符不起作用。我究竟做错了什么?