小编Dav*_*ine的帖子

项目的默认XML名称空间必须是MSBuild XML名称空间

我在本地克隆了ASP.NET Core SignalR Repo,并尝试在以下环境中打开解决方案.

IDE

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01055
Run Code Online (Sandbox Code Playgroud)

DOT NET CLI

? dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
 Version:            1.0.0-preview2-1-003177
 Commit SHA-1 hash:  a2df9c2576

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64
Run Code Online (Sandbox Code Playgroud)

我最终看到了很多这类错误消息:

..\Repos\SignalR\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj :error:项目的默认XML名称空间必须是MSBuild XML名称空间.如果项目是以MSBuild 2003格式创作的,请添加 xmlns="http://schemas.microsoft.com/developer/msbuild/2003"到元素中.如果项目是以旧的1.0或1.2格式编写的,请将其转换为MSBuild 2003格式. ..\Repos\SignalR\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj

我想知道如何以正确的方式解决这个问题.

msbuild asp.net-mvc visual-studio-2015 .net-core asp.net-core

132
推荐指数
5
解决办法
13万
查看次数

文件可以嵌套在VS2017解决方案资源管理器中用于.NET Core(非ASP.NET核心)项目吗?

在"旧学校"MSBuild项目中 - 例如仍然在VS2017中的Windows窗体中使用 - 文件可以通过DependentUponcsproj文件中的项目"嵌套" .

我用它来在Noda Time中将单元测试组合在一起,例如

<Compile Include="LocalDateTest.PeriodArithmetic.cs">
  <DependentUpon>LocalDateTest.cs</DependentUpon>
</Compile>
Run Code Online (Sandbox Code Playgroud)

这导致了易于导航的测试:

嵌套测试

转向project.json.NET Core时,我故意"丢失"此功能,但希望在转换为MSBuild时会返回.但是,看起来基于.NET Core SDK(根元素<Project Sdk="Microsoft.NET.Sdk">)的MSBuild项目在Visual Studio 2017中得不到相同的处理,即使ItemGroup手动添加与"旧学校"项目相同的元素.

ASP.NET Core项目为缩小的CSS和Javascript接收自动嵌套,但目前尚不清楚如何将其应用于.NET Core库项目中的C#.

msbuild csproj .net-core visual-studio-2017

74
推荐指数
3
解决办法
6844
查看次数

Angular2,禁用锚元素的正确方法是什么?

我正在开发一个Angular2应用程序,我需要显示 - 但是disable一个<a> HTML元素.这样做的正确方法是什么?

更新

请注意*ngFor,这将阻止使用*ngIf和完全渲染的选项<a>.

<a *ngFor="let link of links"
   href="#" 
   [class.disabled]="isDisabled(link)" 
   (click)="onClick(link)">
   {{ link.name }}
</a>
Run Code Online (Sandbox Code Playgroud)

打字稿组件具有类似如下的方法:

onClick(link: LinkObj) {
    // Do something relevant with the object... 
    return false;
}
Run Code Online (Sandbox Code Playgroud)

我需要实际上阻止元素被点击,而不仅仅是出现在CSS中.我假设我首先需要绑定到[disabled]属性,但这是不正确的,因为锚元素没有disabled属性.

我看着并考虑使用pointer-events: none但这阻止了我的cursor: not-allowed工作风格- 这是要求的一部分.

html dom typescript angular2-template angular

59
推荐指数
5
解决办法
11万
查看次数

使用ReSharper 10 Ultimate的Visual Studio 2015 Enterprise - 无法正确解析

我安装了Visual Studio 2015 Enterprise,版本14.0.24720.00 Update 1以及ReSharper 10 Ultimate 10.0.2版.我有一个打字稿文件使用AtScript语法来引用Angular2指令模块作为其注释.但是,ReSharper声明了以下错误:

符号'指令'无法正确解析,可能位于无法访问的模块中.

以下是完整错误工具提示.

在此输入图像描述

应用程序按预期编译和运行,应用程序的角度部分也可以根据需要运行.看起来好像这是一个ReSharper假阴性.是否有人熟悉其他只是禁用ReSharper或忽略警告的解决方法?

resharper visual-studio typescript atscript

23
推荐指数
1
解决办法
6988
查看次数

Visual Studio 2015 ASP.NET 5,Gulp任务不从node_modules复制文件

我试图改变我从这里借来的任务转轮脚本; 在Visual Studio 2015的Task Runner Explorer中成功执行任务运行程序后,实际上并未复制文件.

这是改变的脚本:

/// <binding BeforeBuild='copy-assets' />
"use strict";

var _    = require('lodash'),
    gulp = require('gulp');

gulp.task('copy-assets', function() {
    var assets = {
        js: [
            './node_modules/bootstrap/dist/js/bootstrap.js',
            './node_modules/systemjs/dist/system.src.js',
            './node_modules/angular2/bundles/angular2.dev.js',
            './node_modules/angular2/bundles/router.dev.js',
            './node_modules/angular2/bundles/angular2-polyfills.js',
            './node_modules/angular2/bundles/http.dev.js',
            './node_modules/rxjs/bundles/Rx.js',
            './node_modules/typescript/lib/typescript.js'
        ],
        css: ['./node_modules/bootstrap/dist/css/bootstrap.css']
    };
    _(assets).forEach(function(assets, type) {
        gulp.src(assets).pipe(gulp.dest('./webroot/' + type));
    });
});
Run Code Online (Sandbox Code Playgroud)

任务运行器似乎在Visual Studio 2015 Enterprise中没有错误地运行,但之后我的wwwroot/jswwwroot/css中没有文件?

在此输入图像描述

这是文件结构:

在此输入图像描述

我做错了什么,如何解决这个问题?任何和所有的帮助非常感谢!

npm gulp asp.net-core-mvc asp.net-core angular

15
推荐指数
1
解决办法
5349
查看次数

无法让ConfigurationBuilder从ASP.NET Core 1.0 RC2中的xunit类库中的appsettings.json读取

我试图在XUnit项目中执行以下操作,以获取我的测试应该使用的数据库的连接字符串:

public class TestFixture : IDisposable
{
    public IConfigurationRoot Configuration { get; set; }
    public MyFixture()
    {
        var builder = new ConfigurationBuilder()
            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
        Configuration = builder.Build();
    }

    public void Dispose()
    {    
    }
}
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为它在Startup.cs中使用时在WebAPI和MVC模板中完美运行.此外,此代码以前在RC1中使用dnx工作,但现在我将所有内容更新到RC2和Core CLI,它不再能够找到appsettings.jsonxunit类库的根目录中的文件.

这是我的测试类的样子,所以你可以看到我如何调用配置:

public class MyTests : IClassFixture<MyFixture>
{
    private readonly MyFixture _fixture;
    public MyTests(MyFixture fixture)
    {
        this._fixture = fixture;
    }

    [Fact]
    public void TestCase1()
    {
        ICarRepository carRepository = new CarRepository(_fixture.Configuration);
    }
}
Run Code Online (Sandbox Code Playgroud)

asp.net xunit xunit.net xunit2 asp.net-core

15
推荐指数
2
解决办法
8846
查看次数

如何等待RxJS内部订阅方法

在RxJS主题的​​订阅回调中,我想要await一个async函数.下面是打字稿发布者抱怨说的代码示例:

错误:(131,21)TS2304:找不到名称'await'.

async ngOnInit() {
  this.subscriber = dateSubscription.subscribe((date: Date) => {
    let dbKey = await this._someService.saveToDatabase(someObject);
    // wait for db write to finish before evaluating the next code
    // ... some other code here
  });
}
Run Code Online (Sandbox Code Playgroud)

通常我在尝试在非async函数内调用await时会看到这个.我是否需要进行订阅回调async或者我是否会犯这个错误?该函数saveToDatabaseasync并返回一个解析为写入的数据库主键的promise.

async-await rxjs typescript angular

13
推荐指数
5
解决办法
3万
查看次数

npm发布是否执行npm包

考虑到Node.js包管理器,即npm - 如果发布命令在发布之前执行pack命令或者它是否完全不同,我很好奇?所以,如果我要执行:

npm publish <folder>
Run Code Online (Sandbox Code Playgroud)

它首先执行以下操作:

npm pack <folder>
Run Code Online (Sandbox Code Playgroud)

我无法找到文档中提到的任何内容.


主要的原因我很好奇这是我们的构建过程仅仅是做npm publish没有明确npm pack之前,但不包出现有预期的内容.即; 的内容.tgz,当我执行本地不同npm pack到的内容npm publish.

node.js npm npm-publish

11
推荐指数
1
解决办法
948
查看次数

C#bool是原子的,为什么volatile是有效的

C#中,我们知道a bool是原子的 - 那么为什么将它标记为有效volatile呢?有什么不同,什么是一个好的(甚至是实际的)用例?

bool _isPending;
Run Code Online (Sandbox Code Playgroud)

volatile bool _isPending; // Is this realistic, or insanity?
Run Code Online (Sandbox Code Playgroud)

我在这里这里做了一些阅读,我正在努力确保我完全理解两者的内部运作.我想知道什么时候使用一个与另一个相比,或者只是bool足够.

c# multithreading boolean atomic volatile

11
推荐指数
2
解决办法
1378
查看次数

简化通用类型推断

我正在编写一个通用代码,它应该处理从多个源加载数据的情况.我有一个带有以下签名的方法:

public static TResult LoadFromAnySource<TContract, TSection, TResult>
    (this TSection section, 
          string serviceBaseUri, 
          string nodeName)
    where TSection : ConfigurationSection
    where TResult : IDatabaseConfigurable<TContract, TSection>, new() 
    where TContract : new()
Run Code Online (Sandbox Code Playgroud)

但它是一个矫枉过正:当我通过TResult,我已经知道什么TContractTSection确切的.在我的例子中:

public interface ISourceObserverConfiguration 
    : IDatabaseConfigurable<SourceObserverContract, SourceObserverSection>
Run Code Online (Sandbox Code Playgroud)

但我必须写下面的内容:

sourceObserverSection.LoadFromAnySource<SourceObserverContract, 
                                        SourceObserverSection, 
                                        SourceObserverConfiguration>
    (_registrationServiceConfiguration.ServiceBaseUri, nodeName);
Run Code Online (Sandbox Code Playgroud)

您可以看到我必须指定<SourceObserverContract, SourceObserverSection>两次对,这违反了DRY原则.所以我想写一些类似的东西:

sourceObserverSection.LoadFromAnySource<SourceObserverConfiguration>
   (_registrationServiceConfiguration.ServiceBaseUri, nodeName);
Run Code Online (Sandbox Code Playgroud)

从界面制作SourceObserverContractSourceObserverSection推断.

是否有可能在C#或我应该手动指定它?

IDatabaseConfigurable 好像:

public interface IDatabaseConfigurable<in TContract, in TSection> 
    where TContract : ConfigContract
    where TSection : ConfigurationSection …
Run Code Online (Sandbox Code Playgroud)

.net c# generics

10
推荐指数
1
解决办法
424
查看次数