我正在尝试将TeamCity配置为与NuGet一起使用.到目前为止 - 没有运气.我配置了4个构建步骤:
但是,当我触发构建时,我甚至无法通过第一个构建步骤.我配置TC来下载丢失的NuGet包.当我运行构建时,TC说:
无法在{here_is_my_path}找到repositories.config".
我知道问题是我使用这个名为的VS功能Enable NuGet package restore- 因此,repositories.config我的解决方案文件夹中没有这样的文件,这就是为什么TC无法找到它并且构建失败的原因.那么,我该怎么配置TC呢?任何想法和帮助表示赞赏.
如果有帮助,我正在使用.NET 4.0,VS2010和TeamCity 7.
我正在尝试在启动时将我的ASP.NET核心应用程序自行注册到Consul注册表,并在关闭时注销它.
从这里我可以收集调用http api [ put /v1/agent/service/register]可能是要走的路(或者可能不是!).
从我的应用程序中,我认为我将定位Startup该类,从添加我的.json文件开始
public Startup(IHostingEnvironment env)
{
var builder = new Configuration().AddJsonFile("consulconfig.json");
Configuration = builder.Build();
}
Run Code Online (Sandbox Code Playgroud)
但是现在,我被卡住了,因为ConfigureServices方法告诉我这是我向容器添加服务的地方,而Configure方法是我配置Http请求管道的地方.
有人指出我正确的方向,在线阅读,例子等
我想在我的ASP.NET核心应用程序中使用Hangfire,我有错误消息:
没有注册类型服务
这是我的代码:服务:
public class MyService: IMyService
{
private readonly MyContext _context;
public MyService(MyContext context)
{
_context = context;
}
// some code
}
public interface IMyService
{
//some code
}
Run Code Online (Sandbox Code Playgroud)
在Startup.cs中:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IMyService, MyService>();
// another services
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider)
{
app.UseHangfireDashboard();
app.UseHangfireServer();
RecurringJob.AddOrUpdate(() => serviceProvider.GetService<IMyService>().MyMethod(), Cron.Minutely);
}
Run Code Online (Sandbox Code Playgroud)
你知道服务没有注册的原因吗?
我目前在使用swagger授权api调用身份服务器4时遇到问题.
我的swagger依赖是使用swashbuckle版本-beta客户端对象在身份服务器4中看起来像
new Client
{
ClientId="swagger",
Enabled = true,
ClientName="Swagger",
AllowedGrantTypes = GrantTypes.Implicit,
ClientSecrets = new List<Secret>
{
new Secret("secret".Sha256())
},
AllowedScopes = new List<string>
{
"apil"
},
RedirectUris = new List<string>
{
"http://localhost:15138/swagger/ui/popup.html"
},
AllowedCorsOrigins = new List<string>
{
"http://localhost:15138",
"http://localhost:15138"
},
AllowAccessTokensViaBrowser = true,
AllowAccessToAllScopes= true
}
Run Code Online (Sandbox Code Playgroud)
客户端对象是身份验证的配置方法中的身份服务器4模型
app.UseIdentityServer();
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>();
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = "http://localhost:15138/",
ScopeName = "apil",
RequireHttpsMetadata = false,
});
Run Code Online (Sandbox Code Playgroud)
使用fiddler我的get请求看起来像这样
GET /connect/authorize?state=9321480892748389&nonce=5279296493808222&client_id=swagger&redirect_uri=http%3A%2F%2Flocalhost%3A15138%2Fswagger%2Fui%2Fpopup.html&response_type=id_token%20token&scope=apil HTTP/1.1
所有必要的参数都在那里,客户端具有相应的客户端ID,但我得到的响应是重定向到错误页面,其中包含无效请求的消息.我期待一个登录页面传递凭据或类似的东西获得授权我想知道我做错了什么.
VS2015 Pro,.NET Core,Web应用程序。
我试图弄清楚如何从具有嵌套对象的appsettings中获取对象。我可以通过创建具有与配置名称匹配的简单类型的POCO来处理单级对象。但是对于更复杂的对象,它不起作用。我正在返回顶级对象,但它们又返回了null。这是我到目前为止的内容:
StartUp.ConfigureServices:
appsettings.json:
POCO APIContext:
使用类:
因此,我取回了三个API对象,但它们都为空。我对Startup.cs中的Configuration不太了解,但是应该知道它应该是什么样子。
configuration appsettings visual-studio-2015 .net-core asp.net-core
我尝试使用xUnit test runner 2(实际上是1.1.3).不幸的是它不支持.NET Core,它只适用于完整的.NET 4.5:

因此,TC代理无法运行测试.我检查了文档,发现它已经过时了.我在官方xUnit Slack服务器上询问- 感谢@naile 没有反馈.
netcoreapp1.1用作唯一项目的目标框架.更多详情:
xUnit.net 2.2.0
Teamcity 10
VS2017
new *.csproj project format
Run Code Online (Sandbox Code Playgroud) 我的模型类中有一个属性用户名,我想对其进行验证以限制用户输入任何空格或逗号。目前,它仅使用以下正则表达式来限制空白,但我也想限制逗号。请建议
[Required]
[Display(Name = "UserName")]
[RegularExpression(@"^\S*$", ErrorMessage = "Username Cannot Have Spaces")]
public string UserName { get; set; }
Run Code Online (Sandbox Code Playgroud) 我试图映射具有子对象的集合,我发现忽略同一类型的对象的()应用到性能子对象上似乎嗯...忽视!
这是一个演示问题的单元测试.
class A
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<B> Children { get; set; }
}
class B
{
public int Id { get; set; }
public string Name { get; set; }
}
[TestClass]
public class UnitTest1
{
[TestInitialize()]
public void Initialize()
{
Mapper.CreateMap<A, A>()
.ForMember(dest => dest.Id, opt => opt.Ignore());
Mapper.CreateMap<B, B>()
.ForMember(dest => dest.Id, opt => opt.Ignore());
}
[TestMethod]
public void TestMethod1()
{
A src = …Run Code Online (Sandbox Code Playgroud) 我正在研究在 React.js 客户端应用程序和建立在关系 SQL 数据库之上的服务器应用程序之间使用 GraphQL 的可能性。应在客户端创建查询,包括复杂的 SQL 样式语句,例如:
WHERE Customer.Age BETWEEN 22 AND 25
AND Order.Status = 'Active'
OR Product.Name LIKE '%foo%'
Run Code Online (Sandbox Code Playgroud)
这意味着客户端通常应该只接收一小部分记录(例如 10 而不是 10M)。
这篇看起来不错的Phil Sturgeon 文章宣称了一些奇怪的事情:
我希望 GraphQL 可以帮助客户定义他们自己的范围,将这些包含过滤为适当的数据本身,这将有助于识别 API 应该添加为方便方法的范围包含。
在这种情况下,GraphQL 似乎对 API 开发人员没有帮助,但似乎确实有人谈论在未来添加 @filter 来做到这一点。
在将来?现在 GraphQL 中没有过滤?我继续研究并发现了这个 SO 问题和这个惊人的交互式 Graphcool 文档。这两个示例都使用了一个filter由一组后缀调用的功能,例如_gte:
query combineMovies {
allMovies(filter: {
OR: [{
AND: [{
releaseDate_gte: "2009"
}, {
title_starts_with: "The Dark Knight"
}]
}, {
title: "Inception" …Run Code Online (Sandbox Code Playgroud) 我有ASP.NET Core API.我已经阅读了这里的文档,展示了如何在asp.net核心中进行集成测试.该示例设置测试服务器,然后调用控制器方法.
但是我想直接测试一个特定的类方法(不是控制器方法)?例如:
public class MyService : IMyService
{
private readonly DbContext _dbContext;
public MyService(DbContext dbContext)
{
_dbContext = dbContext;
}
public void DoSomething()
{
//do something here
}
}
Run Code Online (Sandbox Code Playgroud)
当测试开始时,我希望startup.cs被调用,以便所有依赖项都会被注册.(比如dbcontext)但是我不确定在集成测试中如何解决IMyService?
注意:我想DoSomething()直接测试方法的原因是因为任何控制器都不会调用此方法.我Hangfire在此API中使用进行后台处理.Hangfire的后台处理作业将调用DoSomething()方法.因此,对于集成测试,我想避免使用Hangfire并直接调用DoSomething()方法
c# ×5
asp.net-core ×4
.net-core ×3
teamcity ×2
api-design ×1
appsettings ×1
asp.net ×1
asp.net-mvc ×1
automapper ×1
consul ×1
coreclr ×1
csproj ×1
graphql ×1
hangfire ×1
nuget ×1
swagger ×1
swashbuckle ×1
web-services ×1
xunit ×1
xunit.net ×1