小编Ser*_*ock的帖子

Powershell import-module找不到模块

我正在学习PowerShell,我正在尝试构建自己的模块库.

我写了一个简单的模块XMLHelpers.psm1并放入我的文件夹$home/WindowsPowerShell/Modules.

当我做:

 import-module full_path_to_XMLHelpers.psm1
Run Code Online (Sandbox Code Playgroud)

有用.但当我这样做时:

import-module XMLHelpers
Run Code Online (Sandbox Code Playgroud)

它不起作用,我收到错误:

Import-Module:未加载指定的模块"xmlhelpers",因为在任何模块目录中都找不到有效的模块文件.

我检查过环境变量PSModulePath包含这个文件夹.由于它是一个网络文件夹,我还尝试将其移动到本地文件夹并进行修改PSModulePath但没有成功

 $env:PSModulePath=$env:PSModulePath+";"+'C:\local'
Run Code Online (Sandbox Code Playgroud)

有什么可能导致这个问题的想法吗?

powershell module

47
推荐指数
5
解决办法
20万
查看次数

MSBuild:并行构建和.Net项目

我编写了一个MSBuild项目文件,试图并行构建我的VS2010解决方案的所有配置:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <ItemGroup>
    <BuildFile Include="$(SourceRoot)MyProject.sln" />
    <Config Include="Debug">
      <Configuration>Debug</Configuration>
    </Config>
    <Config Include="Release">
      <Configuration>Release</Configuration>
    </Config>
  </ItemGroup>

  <Target Name="BuildAll" Outputs="%(Config.Configuration)">
    <Message Text="Start building for configuration: %(Config.Configuration)" />
    <MSBuild Projects="@(BuildFile)"
             Properties="Configuration=%(Config.Configuration)"
             Targets="Build" />
  </Target>  
</Project> 
Run Code Online (Sandbox Code Playgroud)

我用以下命令启动msbuild:

msbuild /m /p:BuildInParallel=true /t:BuildAll buildall.proj 
Run Code Online (Sandbox Code Playgroud)

问题是我的解决方案有许多.Net项目都有相同的输出文件夹.这些项目也使用相同的外部程序集.

因此,通常会同时生成两个输出可执行文件,并同时复制它们的依赖项.这会导致错误,例如:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3001,9): 
error MSB3021: 
Unable to copy file "xxx\NLog.dll" to "D:\src\Blackbird\shared\bin\debug\NLog.xml". The process 
cannot access the file 'xxx\NLog.dll because it is being used by another process. 
Run Code Online (Sandbox Code Playgroud)

我认为这意味着:"2个不同的项目使用NLog并尝试同时在输出文件夹中复制其程序集"......

有没有办法解决这个问题?我真的想避免修改解决方案中的所有项目.

查看任务源代码"C:\ Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3001,9)",我看到有可能使msbuild重试该副本:

<Copy
    SourceFiles="@(ReferenceCopyLocalPaths)"
    DestinationFiles="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"
    SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
    OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
    Retries="$(CopyRetryCount)"
    RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
    UseHardlinksIfPossible="$(CreateHardLinksForCopyLocalIfPossible)"
    Condition="'$(UseCommonOutputDirectory)' …
Run Code Online (Sandbox Code Playgroud)

msbuild parallel-processing build

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

如何建立一个指向VARIANTs的SAFEARRAY指针?

我正在尝试使用以下方法的COM组件:

HRESULT _stdcall Run(
    [in] SAFEARRAY(BSTR) paramNames,
    [in] SAFEARRAY(VARIANT *) paramValues
    );
Run Code Online (Sandbox Code Playgroud)

如何在C/C++中创建paramValues数组?

c++ com variant safearray

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

在同一进程中的同一文件上创建2个FileStream

我正在尝试创建一个将自动删除的临时文件.

stream = new FileStream(
           tmpFilePath, 
           FileMode.OpenOrCreate, 
           FileAccess.ReadWrite, 
           FileShare.ReadWrite, 
           4096, 
           FileOptions.DeleteOnClose|FileOptions.RandomAccess
           );
Run Code Online (Sandbox Code Playgroud)

该文件将由第三方API使用,该API也将创建FileStream:

stream = new FileStream(
          tmpFilePath, 
          FileMode.Open, 
          FileAccess.Read, 
          FileShare.Read);
Run Code Online (Sandbox Code Playgroud)

我想我已经尝试了所有可能的标志组合,但我总是得到一个"进程无法访问文件'XXX',因为它正在被另一个进程使用......"

难道我做错了什么?有办法吗?

.net c# file-sharing filestream

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

Python for .Net:运行嵌入式解释器

我正在尝试使用 Python3.2 使用 Python.Net 版本在以下位置找到:https : //github.com/renshawbay/pythonnet

我正在使用以下简单的测试程序:

using System;
using System.IO;
using Python.Runtime;

namespace TestPythonNet
{
    class Program
    {
        static void Main(string[] args)
        {
            string binDir = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(Program)).Location);
            string pyHome = @"D:\src\scratch\TestPythonNet\TestPythonNet\PythonRuntime";
            PythonEngine.PythonHome = @"D:\src\scratch\TestPythonNet\TestPythonNet\PythonRuntime";
            PythonEngine.ProgramName = "PythonRuntime";
            Environment.SetEnvironmentVariable("PYTHONPATH",
                Path.GetFullPath(Path.Combine(pyHome, "DLLs")) + ";" +
                Path.GetFullPath(Path.Combine(pyHome, "Lib")) + ";" +
                Path.GetFullPath(Path.Combine(pyHome, "Lib", "site-packages")) + ";" +
                binDir
                );
            Environment.SetEnvironmentVariable("PYTHONVERBOSE", "1");
            PythonEngine.Initialize();
            PythonEngine.ImportModule("clr");
            using (Py.GIL())
            {
                PythonEngine.RunSimpleString(
                    "import clr; " +
                   "a = clr.AddReference('System'); " +
                    "print(a.Location);" +
                    "from System …
Run Code Online (Sandbox Code Playgroud)

.net c# python python-3.x python.net

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