小编Pas*_*ger的帖子

使用PowerShell修改JSON文件而不编写BOM

我需要使用PowerShell修改现有的UTF8编码的JSON文件.我尝试使用以下代码:

$fileContent = ConvertFrom-Json "$(Get-Content $filePath -Encoding UTF8)"
$fileContent.someProperty = "someValue"
$fileContent | ConvertTo-Json -Depth 999 | Out-File $filePath
Run Code Online (Sandbox Code Playgroud)

这会将BOM添加到文件中,并以UTF16格式对其进行编码.是否可以拥有ConvertFrom-JsonConvertTo-Json不执行编码/ BOM?

unicode powershell byte-order-mark

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

未为NuGet包添加参考

我有一个自定义的NuGet包(My.Resources),其中包含一个程序集和对另一个自定义的NuGet包(My.Base)的依赖。

如果我安装了软件包,则安装成功完成,但是未添加程序集引用。这是Install-Package命令的完整输出:

Attempting to resolve dependency 'My.Base (? 1.0.0)'.
Installing 'My.Base 1.0.0'.
Added file 'My.Base.dll' to folder 'My.Base.1.0.0\lib\net45'.
Added file 'My.Base.1.0.0.nupkg' to folder 'My.Base.1.0.0'.
Successfully installed 'My.Base 1.0.0'.
Installing 'My.Rsources 1.1.0-beta0001'.
Added file 'My.Resources.dll' to folder 'My.Resources.1.1.0-beta0001\lib\net45'.
Added file 'My.Resources.XML' to folder 'My.Resources.1.1.0-beta0001\lib\net45'.
Added file 'My.Resources.1.1.0-beta0001.nupkg' to folder 'My.Resources.1.1.0-beta0001'.
Successfully installed 'My.Resources 1.1.0-beta0001'.
Adding 'My.Base 1.0.0' to WindowsFormsApplication8.
For adding package 'My.Base 1.0.0' to project 'WindowsFormsApplication8' that targets 'net45',
>> Assembly references are being added from 'lib\net45'
Added …
Run Code Online (Sandbox Code Playgroud)

assembly-references nuget nuget-package

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

在LINQ中反转嵌套集合

有一个类型A的列表,每个包含一个类型B的列表,获取所有类型B的列表的最佳方法是什么,每个类型包含它们所属的类型A的列表?

有一个如下列表:

var parents = new List<Parent> {
    {
        new Parent {
            ID = 1,
            Childs = new List<Child> {
                {
                    new Child {
                        ID = 1
                    }
                },
                {
                    new Child {
                        ID = 2
                    }
                },
                {
                    new Child {
                        ID = 3
                    }
                }
            }
        }                    
    },
    {
        new Parent {
            ID = 2,
            Childs = new List<Child> {
                {
                    new Child {
                        ID = 3
                    }
                },
                {
                    new Child {
                        ID = 4
                    }
                }, …
Run Code Online (Sandbox Code Playgroud)

c# linq

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

在 Visual Studio 2017 中使用 LFS

我不想将 Visual Studio 2017 (15.5) 与使用 Git LFS 跟踪某些文件的 Git 存储库一起使用。

我已经在机器上安装了 Git 2.15,其中包含 Git LFS。

我安装的 Visual Studio 2017 只安装了以下工作负载,没有安装 Git 组件,因为它已经在机器上可用:

--add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Microsoft.VisualStudio.Workload.NetCoreTools --add Microsoft.VisualStudio.Component.Wcf.Tooling

Visual Studio 现在无法从存储库签出分支,因为它找不到 Git LFS。

我认为这是因为git-lfs.exe在路径上不可用,并且 Visual Studio 在c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin\.

如果我另外安装了独立的 git-lfs 安装程序,它git-lfs在路径上可用,结帐可以在某些机器上运行,但不能在其他机器上运行(还没有发现有什么区别,可能是安装顺序,或者是新安装或更新视觉工作室)。

如果我删除该c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\文件夹,则在 Visual Studio 中一切正常,因为它确实使用了路径中可用的 Git 版本。

我的问题是:

  1. 在 Visual Studio 中获得 Git LFS 支持的假设方法是什么?
  2. 有没有办法让 Visual Studio 在路径上使用 Git …

visual-studio team-explorer git-lfs visual-studio-2017

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