我正在尝试为 dotnet core 编写一个自定义代码生成器,但到目前为止几乎没有成功,因为它周围的文档有限。
仔细研究了 CodeGeneration 源代码,了解了如何从命令行触发生成器以及它的内部工作原理。
由于 dotnet core 中可用的生成器不能满足我的需求,我尝试编写自己的 CodeGenerator,但似乎无法通过“dotnet aspnet-codegenerator”命令调用它。下面是我的自定义代码生成器(目前没有实现 - 我的目标是能够从 dotnet cli 触发它并以异常结束),
namespace TestWebApp.CodeGenerator
{
[Alias("test")]
public class TestCodeGenerator : ICodeGenerator
{
public async Task GenerateCode(TestCodeGeneratorModel model)
{
await Task.CompletedTask;
throw new NotImplementedException();
}
}
public class TestCodeGeneratorModel
{
[Option(Name = "controllerName", ShortName = "name", Description = "Name of the controller")]
public string ControllerName { get; set; }
[Option(Name = "readWriteActions", ShortName = "actions", Description = "Specify this switch to generate Controller with read/write …Run Code Online (Sandbox Code Playgroud) 我一直在使用dotnet Core(用于API)和Angular2开发一个简单的应用程序,以便同时学习它们.
我在命令行上使用Yeoman创建了项目,并且很高兴在Visual Studio Code(在Windows上)编写代码.所有人似乎都很好地融合在一起,这是一次愉快的经历.
我想我可能会尝试使用Visual Studio 2017,看看在VS中开发一个dotnet Core项目的经历是什么样的.
但是,安装VS2017并从github克隆项目后,我不确定如何继续.我看不到任何恢复/构建/运行项目的方法.
克隆了repo后,我看到我的项目显示在Solution Explorer中,project.json文件可见.但是,Debug | 开始是灰色的.我在某处看到VS2017需要将project.json转换为新的(旧的)XML格式,我也觉得我错过了一个.sln文件.
如果有人能指出我正确的方向,我将不胜感激.
我正在迁移使用.NET Core SDK 1.0.0-preview2-1-003177构建的解决方案,因为我想在Visual Studio 2017中使用它.我使用.NET Core SDK 1.0.1中的dotnet migrate命令,它运行良好,它汇编.当我使用IIS Express运行Web部件时,包含的经典Program.cs
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
Run Code Online (Sandbox Code Playgroud)
使用此异常在Build()崩溃
System.MissingMethodException:'找不到方法:'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.'
我根本找不到原因.
我正在尝试将NuGet包发布到私有VSTS订阅源.我想只使用.NET CLI 实现这一点,而无需创建或修改nuget.config文件.
我试过这样做:
dotnet nuget push <PackageName> --source https://XXX.pkgs.visualstudio.com/_packaging/YYY/nuget/v3/index.json --api-key <VSTS UserName>:<PersonalAccessToken>
Run Code Online (Sandbox Code Playgroud)
我明白了:
error: Unable to load the service index for source https://XXX.pkgs.visualstudio.com/_packaging/YYY/nuget/v3/index.json.
error: Response status code does not indicate success: 401 (Unauthorized).
我可以在Fiddler中看到.NET CLI只发送一个GET请求而https://XXX.pkgs.visualstudio.com/_packaging/YYY/nuget/v3/index.json没有任何授权令牌.该请求以401结尾.
我有一个ASP.NET Core 2.0应用程序,并且Angular 5 SPA托管在同一文件夹中。
当前要部署到IIS,我需要执行以下操作:
// First publish the release configuration
dotnet publish -c release
// Now delete the wwwroot directory as it is pulished with ng build
rm -r bin/release/netcoreapp2.0/publish/wwwroot
// Build the prod version of the angular app
ng build --prod
// copy the new wwwroot folder into the publish folder
cp -R wwwroot bin/release/netcoreapp2.0/publish/
Run Code Online (Sandbox Code Playgroud)
这非常令人困扰...我如何告诉dotnet publish运行ng build --prod?
我尝试将以下内容添加到我的项目csproj文件中:
<Target Name="AngularBuild" AfterTargets="Publish">
<Exec Command="npm run build --prod" />
</Target>
Run Code Online (Sandbox Code Playgroud) 我们有一个项目依赖于自定义 NuGet feed(也托管在 VSTS 中)。
我正在尝试整合一个新阶段来生成代码覆盖率报告,如这篇博客文章中所示。我的新阶段如下所示:
并由以下步骤组成:
dotnet restore在“使用此 VSTS/TFS feed 中的包”下拉列表中选择我的自定义 feeddotnet test使用相关参数来收集代码覆盖率问题是dotnet test坚持尝试恢复包本身。由于我找不到方法告诉它使用自定义源,因此在尝试恢复这些包时失败:
D:\a\1\s\MyProject\MyProject.csproj : error NU1101: Unable to find package My.Package. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org
我的主要构建过程运行良好,并且能够从自定义源恢复包。区别在于使用 Visual Studio(即非dotnet)版本的命令:
处理这个问题的正确方法是什么?
我是否需要找到某种方式来讲述dotnet test我的自定义 Feed?
或者(假设我restore之前正在运行)我是否需要说服它完全跳过恢复?
continuous-integration azure-devops dotnet-cli dotnet-restore dotnet-test
我是 .NET 新手,正在学习 Angular 和 .NET Core 的在线课程,同时使用 VS Code。该课程需要安装AutoMapper.Extensions.Microsoft.DependencyInjection包,但当我尝试安装任何包时,我不断收到以下错误。
无法解析“.NETCoreApp,Version=v2.2”的 <package_name>
包 <package_name> 与项目 <csproj_path> 中的“所有”框架不兼容
我使用以下命令安装软件包:
dotnet add package AutoMapper.Extensions.Microsoft.DependencyInjection
Run Code Online (Sandbox Code Playgroud)
到目前为止我尝试过的:
当我在课程开始时尝试安装Microsoft.EntityFrameworkCore.Sqlite包时,它之前工作过,现在由于某种原因我无法安装任何包。
请注意,我无法使用 NuGet 扩展,因为它不在公司代理后面工作。
任何帮助将不胜感激 :)
GitLab now supports nuget public and private feed repository.
I've got a public project (e.g: https://gitlab.com/sunnyatticsoftware/sasw-test-support)
I create an access token for my user with api and write_repository (e.g: AAABBBCCCDDD)
I create a group variable in my CI/CD: SASW_API_ACCESS_TOKEN: AAABBBCCCDDD. All normal.
Then I create the multi stage CI/CD script to build, pack and publish.
When attempting to publish the nuGet package with the following:
dotnet nuget push **/*.nupkg --source https://gitlab.com/api/v4/projects/17141695/packages/nuget/index.json --api-key AAABBBCCCDDD --skip-duplicate
I get the …
如果要创建使用.NET Framework的ASP.NET Core 1.0应用程序,是否使用.NET CLI?.NET CLI仅适用于新的.NET Core库,还适用于Core和.NET 4.6?
当我使用dotnet new angular和生成一个新的Angular 4项目时ng new,两个生成的项目之间的主要区别是什么?
我做了一个文件夹比较非常快,并告诉我他们在这个级别上有一些差异.我对这些差异不是很感兴趣.
我只对少数高层差异感兴趣.一个例子是在一个项目中拆分模块以进行预渲染而不是另一个项目.考虑到脚手架项目的规模,差异列表不会超过10,所以我肯定会问这里的高层差异不是一个问题.
dotnet-cli ×10
asp.net-core ×4
.net-core ×3
c# ×3
angular ×2
asp.net-mvc ×2
nuget ×2
angular-cli ×1
asp.net ×1
azure-devops ×1
dotnet-test ×1
gitlab ×1
gitlab-ci ×1