【问题标题】:Reference Includes source that is not in the repository参考 包括不在存储库中的源
【发布时间】:2018-11-09 23:41:30
【问题描述】:

我已经克隆了代码for autorest.csharp 和它的子模块 但是测试项目缺少依赖项

构建错误是

Error   CS0234  The type or namespace name 'Modeler' 
does not exist in the namespace 'AutoRest' 
(are you missing an assembly reference?)    autorest.csharp.test

但是解决方案文件包含以下内容

  <ItemGroup>
   <Reference Include="autorest.modeler">
      <HintPath>$(SolutionDir)\node_modules\@microsoft.azure\autorest.modeler\src\bin\netcoreapp2.0\autorest.modeler.dll</HintPath>
      <!-- <HintPath>C:\work\oneautorest\autorest.modeler\src\bin\netcoreapp2.0\autorest.modeler.dll</HintPath> -->
    </Reference>
    <ProjectReference Include="$(SolutionDir)src/autorest.csharp.csproj" />
  </ItemGroup>

如何包含缺少的依赖项的代码(或者如果需要的话 .dll)?

我可以看到建模器的来源在 this repository 但我应该如何访问它?

【问题讨论】:

    标签: autorest


    【解决方案1】:

    @microsoft.azure/autorest.modeler 在package.json devDependencies section 中声明。

    That devDependencies 部分描述为:

    如果有人计划在他们的程序中下载和使用您的模块,那么他们可能不想或不需要下载和构建您使用的外部测试或文档框架。

    在这种情况下,最好将这些附加项映射到 devDependencies 对象中。

    这些东西将在从包的根目录执行npm link 或npm install 时安装,并且可以像任何其他 npm 配置参数一样进行管理。

    所以在你的情况下,试试:

    NODE_ENV=development npm install
    

    对于 Windows:

    cmd /v /c "set NODE_ENV=development&& npm install"
    

    (不是development 和&amp;&amp; 之间缺少空间:这很重要)

    为了获取和安装开发依赖以及主要的生产项目。

    或者,如“npm install won't install devDependencies”中所述:

    npm install --only=dev
    

    同时检查 npm config 生产值是否设置为 true。如果此值为 true,它将跳过 dev 依赖项。

    另外:运行npm config get production,确保它设置为false:

    npm config set -g production false
    

    如果npm install --only=dev/npm rebuild不起作用,您可能需要删除node_modules和package-lock.json并再次运行npm install

    【讨论】:

    • 我安装了 npm 我得到 NODE_ENV 不是内部或外部命令、可运行程序或批处理文件
    • 是的,在 Windows 上,synax 会有所不同。 npm install --only=dev 是否至少允许您获得那些开发依赖项?
    • 是的,现在运行它
    • @KirstenGreed 我已编辑答案以添加NODE_ENV 的 Windows 语法。
    • 我在此Predefined type 'System.Void' is not defined or imported autorest.csharp.test 后收到以下错误。有接受者吗?
    猜你喜欢
    • 1970-01-01
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-26
    • 2010-11-24
    • 2013-06-22
    • 2018-12-04
    相关资源
    最近更新 更多