简体   繁体   English

Azure 管道 - '名称空间中不存在类型或名称空间名称'基础设施''

[英]Azure pipeline - 'The type or namespace name 'Infrastructure' does not exist in the namespace'

I know this question has countless asking already.我知道这个问题已经有无数问了。 However, I didn't find any working solution for me.但是,我没有找到任何适合我的解决方案。

I have a .NET website project and I am using Entity Framework 6. Locally, the project has no problem, everything is running just fine.我有一个 .NET 网站项目,我正在使用 Entity Framework 6。在本地,该项目没有问题,一切运行良好。 But when I push it to my master branch on GitHub so that it will be deployed to my Azure website, the message shows up:但是,当我将它推送到 GitHub 上的主分支以便将其部署到我的 Azure 网站时,会显示以下消息: 在此处输入图像描述

Here's my yml file:这是我的 yml 文件:

    on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  build-and-deploy:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@master

    - name: Set up .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '3.1.301'

    - name: Restore NuGet packages
      run: nuget restore MyOnlineCV.sln

    - name: Build with dotnet
      run: dotnet build --configuration Release

    - name: dotnet publish
      run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

It's happening on the step 'Build with dotnet'.它发生在“使用 dotnet 构建”步骤上。 How am I supposed to solve it?我该怎么解决? Thank you by advance提前谢谢你

And my.csproj for the curious ones:和 my.csproj 对于好奇的人:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{A9A08EBE-F204-4570-9B5F-1EBE5D3E63AA}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Data</RootNamespace>
    <AssemblyName>Data</AssemblyName>
    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
    </Reference>
    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data.Entity" />
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.Security" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Category.cs">
      <DependentUpon>MyOnlineCVDataModel.tt</DependentUpon>
    </Compile>
    <Compile Include="Diploma.cs">
      <DependentUpon>MyOnlineCVDataModel.tt</DependentUpon>
    </Compile>
    <Compile Include="Experience.cs">
      <DependentUpon>MyOnlineCVDataModel.tt</DependentUpon>
    </Compile>
    <Compile Include="MyOnlineCVDataModel.Context.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>MyOnlineCVDataModel.Context.tt</DependentUpon>
    </Compile>
    <Compile Include="MyOnlineCVDataModel.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>MyOnlineCVDataModel.tt</DependentUpon>
    </Compile>
    <Compile Include="MyOnlineCVDataModel.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>MyOnlineCVDataModel.edmx</DependentUpon>
    </Compile>
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Skill.cs">
      <DependentUpon>MyOnlineCVDataModel.tt</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
    <EntityDeploy Include="MyOnlineCVDataModel.edmx">
      <Generator>EntityModelCodeGenerator</Generator>
      <LastGenOutput>MyOnlineCVDataModel.Designer.cs</LastGenOutput>
    </EntityDeploy>
    <None Include="MyOnlineCVDataModel.edmx.diagram">
      <DependentUpon>MyOnlineCVDataModel.edmx</DependentUpon>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Content Include="DbScripts\drop_create.txt" />
    <Content Include="MyOnlineCVDataModel.Context.tt">
      <Generator>TextTemplatingFileGenerator</Generator>
      <LastGenOutput>MyOnlineCVDataModel.Context.cs</LastGenOutput>
      <DependentUpon>MyOnlineCVDataModel.edmx</DependentUpon>
    </Content>
    <Content Include="MyOnlineCVDataModel.tt">
      <Generator>TextTemplatingFileGenerator</Generator>
      <DependentUpon>MyOnlineCVDataModel.edmx</DependentUpon>
      <LastGenOutput>MyOnlineCVDataModel.cs</LastGenOutput>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="EntityFramework">
      <Version>6.4.4</Version>
    </PackageReference>
    <PackageReference Include="EntityFramework.fr">
      <Version>6.2.0</Version>
    </PackageReference>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

The build already worked sometimes but after one push it just stopped working.构建有时已经工作,但一推后它就停止工作了。 I haven't changed any back-end file tho.我没有更改任何后端文件。 I'm lost我迷路了

Edit编辑

Here's the project packages.config:这是项目packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.4.4" targetFramework="net472" />
  <package id="EntityFramework.fr" version="6.2.0" targetFramework="net472" />
</packages>

You are building your project here with the 4.7.2 framework, but in the yml you are referencing the.Net Core Framework.您在这里使用 4.7.2 框架构建项目,但在 yml 中您引用的是 .Net Core 框架。 Could this be the problem?这可能是问题吗?

Finally to solve the problem, I did this: I uninstalled every Entity Framework nuget.最后为了解决这个问题,我这样做了:我卸载了每个实体框架 nuget。 I removed packages.config and in the.csproj I removed this:我删除了 packages.config 并在 .csproj 中删除了这个:

<ItemGroup>
    <PackageReference Include="EntityFramework">
       <Version>6.4.4</Version>
    </PackageReference>
    <PackageReference Include="EntityFramework.fr">
      <Version>6.2.0</Version>
    </PackageReference>
</ItemGroup>

I reinstalled Entity Framework, here's the new packages.config:我重新安装了实体框架,这是新的 packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.4.4" targetFramework="net472" />
</packages>

And the added lines in the.csproj file:以及 .csproj 文件中添加的行:

<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
...
<None Include="packages.config" />
...
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project is referencing to missing NuGet packages on this computer. Use the NuGet packages restoration option to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is: {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
  </Target>
  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />

Then I committed to git and the pipeline worked correctly.然后我承诺 git 并且管道正常工作。

Note that the step run: nuget restore MyOnlineCV.sln in the pipeline is essential.注意步骤run: nuget restore MyOnlineCV.sln在管道中是必不可少的。 Without it an error appears.没有它就会出现错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 内部版本 - 名称空间“Microsoft”中不存在类型或名称空间名称“OpenApi” - Azure Builds - The type or namespace name 'OpenApi' does not exist in the namespace 'Microsoft' 命名空间“Microsoft”中不存在类型或命名空间名称“Azure” - The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' 命名空间中不存在类型或命名空间名称“Core” - The type or namespace name 'Core' does not exist in the namespace 命名空间中不存在类型或命名空间名称“DirectoryServices”? - The type or namespace name 'DirectoryServices' does not exist in the namespace? 命名空间中不存在类型或命名空间名称“Exchange” - The type or namespace name 'Exchange' does not exist in the namespace 类型或名称空间名称“ Confidence”在名称空间中不存在 - The type or namespace name 'Confidence' does not exist in the namespace 命名空间中不存在类型或命名空间名称 - type or namespace name does not exist in the namespace 命名空间中不存在类型或命名空间名称“优化” - The type or namespace name 'Optimization' does not exist in the namespace 类型或名称空间名称在名称空间中不存在 - The type or namespace name does not exist in the namespace 名称空间中不存在类型或命名空间名称“GetName” - The type or namespace name 'GetName' does not exist in the namespace
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM