我有一个 net472 项目,其中包含使用 xUnit 的单元测试,该项目是我在 VS 2017 中开发的。该项目包含 ASP.NET Core 项目的测试。
我已将其迁移packages.config到PackageReference使用 Visual Studio 的样式。迁移后它仍然可以在 VS 中构建,但使用 MSBuild 构建已损坏。我收到以下错误:
Project "<solution-file-path>.sln" (2) is building "<project-file-path>.csproj" (14) on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): error : Your project file doesn't list 'win-x64' as a "RuntimeIdentifier". You should add 'win-x64' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore. [<project-file-path>.csproj]
Done Building Project "<project-file-path>.csproj" (default targets) -- FAILED.
Run Code Online (Sandbox Code Playgroud)
有人暗示可能是什么原因吗?
最近,Microsoft推出了Office加载项体系结构,该体系结构允许开发远程托管的加载项,并在办公室内的IFrame中运行.我已经阅读了很多,试图了解这个架构是否可以替代VSTO,还是它们有单独的用例.VS 2015有两个模板.
在我的具体情况下,我想开发一个加载项,使用自定义导入功能扩展Excel 2016(例如自定义CSV,TSV,甚至XLSX).我不知道我应该选择哪种类型的项目.
我有一个 ASP.NET Core 网站自托管在安装在多台机器上的 Windows 服务中。我不想对WebRoot目录进行硬编码或依赖于它在ContentRoot Directory.GetCurrentDirectory(). 例如,我希望它可以使用 json 配置文件进行配置,因此我尝试了以下操作:
在 Program.cs 中:
var host = new WebHostBuilder()
.UseKestrel()
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.RunAsService();
Run Code Online (Sandbox Code Playgroud)
在 Startup.cs 中:
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
builder.AddEnvironmentVariables();
Configuration = builder.Build();
env.WebRootPath = Configuration["webroot"];
}
Run Code Online (Sandbox Code Playgroud)
我的 appsettings.json 看起来像这样:
{
"webroot": "C:\\path\\to\\my\\custom\\webroot",
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用。我想知道正确的方法是什么。
编辑:
以下是内容 project.json
{ …Run Code Online (Sandbox Code Playgroud) 在WCF服务中,是否可以在ServiceContract定义中包含数据成员?做这样的事情:
namespace My.Service.Contracts
{
[ServiceContract]
public interface IMyService
{
[OperationContract]
ResultObject[] Search(SearchParams searchParams);
[DataMember]
MyCustomClass MyDataMember { get; }
}
}
Run Code Online (Sandbox Code Playgroud)
我可以MyDataMember从ServiceContract内部公开吗?场景将如下所示:实现服务契约的以下类具有我想使用公共字段/属性公开的成员数据.看起来像这样的东西:我试图在实现服务合同的类中公开一个字段/属性.例如:
public class MyService : IMyService
{
private MyCustomClass _datafield;
ResultObject[] Search(SearchParams searchParams){
//Do the search
}
MyCustomClass MyDataMember {
get: { return _dataField; }
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Angular 4.4.3 反应式表单来为表单中的一组控件实现自定义验证。根据文档,方法AbstractControl.setErrors更新调用该方法的 AbstractControl 的错误属性,更新其父级的状态,但不更新父级的错误属性。我想在 FormGroup 实例上设置错误属性,因此我使用 FormGroup 继承的 setErrors。但是,它不会按预期更新错误。
以下是我的示例代码:在 FormControl 实例上尝试,确实更新了它们的错误及其父级的有效性状态(但不是父级错误!):
let myFormGroup
= this._formBuilder
.group({
ctrl1: [null],
ctrl2: [null]
},
{
validator: (fg: FormGroup) => {
let ctrl1 = fg.get('ctrl1'),
ctrl2 = fg.get('ctrl2'),
ctrl1Empty = !ctrl1.value,
ctrl2Empty = !ctrl2.value;
//Successfully sets ctrl1.errors and fg.status, but not fg.errors
if (ctrl1empty)
ctrl1.setErrors({ctrl1required: true});
//Successfully sets ctrl2.errors and fg.status, but not fg.errors
if (ctrl2Empty)
ctrl2.setErrors({ctrl2required: true});
//Doesn't work, doesn't update fg.errors
if (ctrl1Empty && ctrl2Empty)
fg.setErrors({required: true}); …Run Code Online (Sandbox Code Playgroud) validation typescript angular angular-reactive-forms angular-forms
我正在使用 xUnit 来实现测试。我曾经安装 xUnit Visual Studio runner, xunit.runner.visualstudionuget 包来使用 VS GUI 运行测试。
下面是 VS 中依赖树的 xUnit 相关分支。您可以清楚地看到 xUnit VS runner 没有依赖项:
Visual Studio 突然要求我安装Microsoft.NET.Test.Sdknuget 以便在 GUI 中运行测试。有谁知道为什么?
笔记:
.net ×2
asp.net-core ×2
c# ×2
nuget ×2
xunit ×2
.net-core ×1
angular ×1
asp.net ×1
datacontract ×1
excel ×1
json ×1
ms-office ×1
msbuild ×1
office-js ×1
typescript ×1
unit-testing ×1
validation ×1
vsto ×1
wcf ×1