小编Tia*_*goM的帖子

用于解决方案VS2015的NuGet配置文件(NuGet 3.4+)

好吧,这可能听起来是一个重复的问题,但对于我的搜索,它不是.

我一直在寻找一种在我的解决方案中配置特定nuget包源(url)的正确方法,该源自动生成与解决方案路径相关的所有内容(.nuget文件夹和/或nuget配置文件).

我不想使用APPDATA和MACHINE.

我想只使用解决方案目录,所以当存储库中的另一个用户获取解决方案时,它会正确安装所有内容(包括包文件夹上的nuget引用).

我一直在阅读NuGet文档,看起来,这种方式可以实现并不简单,因为NuGet有不同的版本等等......

有人可以提供简化指南来实现这一目的吗?提前谢谢你的帮助!


更新的问题:

我注意到使用NuGet版本3.4+我不再需要.nu​​get文件夹了!

我的问题/问题是通过解决方案而不是通过machine/appdata配置包源URL,这是因为我使用的是包含公司库源的私有包源URL!谢谢 :)

细节:

我注意到Package Sources URL存储在%APPDATA%\ NuGet\NuGet.Config的NuGet.config文件中.

如何通过解决方案正确配置?这样它很容易在公司业务中维持?

(我的意思是我不需要每个用户在他们的机器上配置源)


来自NuGet文档:

" 解决方案特定的NuGet.Config文件位于解决方案的.nuget文件夹中.此文件中的设置仅适用于解决方案范围的软件包,仅在NuGet 3.3及更早版本中受支持.对于NuGet 3.4及更高版本,它将被忽略."

这是否意味着我无法单独为每个解决方案正确配置源?谢谢!

projects-and-solutions solution nuget nuget-package visual-studio-2015

5
推荐指数
1
解决办法
6090
查看次数

NSubstitute ReturnsForAnyArgs 返回 null 但不应该返回 null

我的测试用例有问题,我试图模拟 my 的返回ICacheProvider,但它总是返回null.

[Fact]
public void Raise_ShoultReturnTrue_IfItsInCache()
{
    var cacheProvider = Substitute.For<ICacheProvider>();
    cacheProvider.Fetch(Arg.Any<string>(), default(Func<IEnumerable<int>>)).ReturnsForAnyArgs(GetFakeCacheDB());

    //I was expecting the var below to contain the data from GetFakeCacheDB method
    var cacheProviderReturn = cacheProvider.Fetch("anything", returnEmpty); 

    //there is more stuff here but doesnt matter for the question    
}

private HashSet<int> returnEmpty()
{
    return new HashSet<int>();
}

private IEnumerable<int> GetFakeCacheDB()
{
    var cacheData = new List<int>()
                    {
                       57352,
                       38752
                    };    
    return cacheData;
}

public interface ICacheProvider
{
    void Add<T>(string key, T …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing nsubstitute

5
推荐指数
1
解决办法
4722
查看次数

ASP.NET Core Web Api发送Access-Control-Allow-Origin:null CORS头和chrome是错误的,如何修复?

昨天我设法让我的API在我的本地计算机上工作,但是今天(相同的代码)在另一台计算机上,它不能正常工作,我在控制台上收到此错误:

无法加载http:// localhost:52056/api/task:'Access-Control-Allow-Origin'标头的值为'null',不等于提供的原点.因此不允许原点'null'访问.

以下是Chrome上的http请求和响应:

在此输入图像描述

(我在IE/Firefox中看不到错误)

这是我的启动类(使用.net core 2)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using TodoApi;

namespace TestCors
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton<ITaskWarehouse, TaskWarehouse>();

            services.AddCors();
            services.AddMvc();
        } …
Run Code Online (Sandbox Code Playgroud)

.net c# cors asp.net-core asp.net-core-webapi

5
推荐指数
1
解决办法
1335
查看次数

将 nodejs 程序的输出重定向到文件时编码错误(Windows 10 powershell 可能存在问题)

我有一个简单的 javascript 文件(我们称之为 index.js),其中包含以下内容:

\n
console.log('p\xc3\xa9rola');\n
Run Code Online (Sandbox Code Playgroud)\n

我在 Windows 10 上使用 VSCode,当我使用以下命令执行文件时,它使用 powershell 作为终端:

\n
node index.js\n
Run Code Online (Sandbox Code Playgroud)\n

我得到以下输出:

\n
p\xc3\xa9rola\n
Run Code Online (Sandbox Code Playgroud)\n

如果我运行以下命令:

\n
node index.js > output.txt\n
Run Code Online (Sandbox Code Playgroud)\n

我在文件中得到以下信息:

\n
p\xe2\x94\x9c\xc2\xaerola\n
Run Code Online (Sandbox Code Playgroud)\n

写入文件时,powershell 的编码似乎存在一些问题,当我在 VSCode 上打开文件时,我可以在右下角看到编码是 UTF-16 LE。

\n

我也已经尝试过以下操作:

\n
node index.js | out-file -encoding utf8 output.txt\n
Run Code Online (Sandbox Code Playgroud)\n

该文件以带有 BOM 的 UTF8 格式保存,但编码仍然错误,因为我看到的是p\xe2\x94\x9c\xc2\xaerola而不是p\xc3\xa9rola

\n

有人可以解释一下这里出了什么问题吗?\n谢谢。

\n

powershell encoding node.js

5
推荐指数
1
解决办法
1138
查看次数

Android Spinner使用具有ID的数组访问图像资源

好的,我尝试仅使用图像制作自定义微调器。我在.xml文件的values文件夹中定义了一个数组,该文件夹中有图像项作为资源..我想用这些图像填​​充微调器。

在res / drawable-mdpi

我有以下图像:

remove_minus_circle_black.png
remove_minus_circle_red.png
remove_minus_sign.png
remove_minus_sign2.png
remove_minus_sign3.png

在res / values / arrays.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <array name="minusIcons">
       <item>@drawable/remove_minus_circle_black</item>
       <item>@drawable/remove_minus_circle_red</item>
       <item>@drawable/remove_minus_sign</item>
       <item>@drawable/remove_minus_sign2</item>
       <item>@drawable/remove_minus_sign3</item>

   </array>

    <array name="directionIcons">

   </array>

</resources>
Run Code Online (Sandbox Code Playgroud)

在res / layout / row.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    />
 </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

现在,我尝试使用自定义适配器将图像添加到微调器的代码(活动本身):

public class Definicoes extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_definicoes);

        Spinner spinner = (Spinner) findViewById(R.id.minusSpinner);

        int[] array = getResources().getIntArray(R.array.minusIcons);
        String [] objects = new String[array.length]; …
Run Code Online (Sandbox Code Playgroud)

android image adapter spinner

2
推荐指数
1
解决办法
2179
查看次数

在TableRow上以编程方式居中TextView

我试图将一个textview集中在一个tablerow中,它本身就在一个tablelayout中,但我想我错过了一些东西,因为TextView没有集中:s

这是我的方法:

private void insertClock() {


        TableLayout table = new TableLayout(this);
        table.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        table.setStretchAllColumns(true);

        TableRow tbRow = new TableRow(this);
        TableLayout.LayoutParams layoutRow = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);




        clock = new TextView(this);
        TableRow.LayoutParams layoutHistory = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);  


        clock.setLayoutParams(layoutHistory);
        clock.setText(calculateClockText());
        tbRow.setLayoutParams(layoutRow);
        table.addView(tbRow);
        clock.setGravity(Gravity.CENTER_HORIZONTAL);
        tbRow.addView(clock);

    }
Run Code Online (Sandbox Code Playgroud)

提前致谢 ;)

android center tablelayout textview tablerow

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