C# Azure管道-x27;类型或命名空间名称';基础设施';命名空间中不存在';
我知道这个问题已经有无数人问了。然而,我没有找到任何有效的解决方案 我有一个.NET网站项目,我正在使用EntityFramework6。 在当地,该项目没有问题,一切正常。但当我将其推送到GitHub上的主分支,以便将其部署到我的Azure网站时,会显示以下消息: 这是我的yml文件:C# Azure管道-x27;类型或命名空间名称';基础设施';命名空间中不存在';,c#,azure,entity-framework,github,github-actions,C#,Azure,Entity Framework,Github,Github Actions,我知道这个问题已经有无数人问了。然而,我没有找到任何有效的解决方案 我有一个.NET网站项目,我正在使用EntityFramework6。 在当地,该项目没有问题,一切正常。但当我将其推送到GitHub上的主分支,以便将其部署到我的Azure网站时,会显示以下消息: 这是我的yml文件: on: push: branches: - master workflow_dispatch: jobs: build-and-deploy: runs-on
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
它发生在“使用dotnet构建”步骤上。我该怎么解决呢?
提前谢谢你
还有我的.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>
调试
任意CPU
{A9A08EBE-F204-4570-9B5F-1EBE5D3E63AA}
图书馆
性质
资料
资料
v4.7.2
512
真的
真的
满的
假的
bin\Debug\
调试;痕迹
促使
4.
pdbonly
真的
bin\Release\
痕迹
促使
4.
..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll
..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll
MyOnlineCVDataModel.tt
MyOnlineCVDataModel.tt
MyOnlineCVDataModel.tt
真的
真的
MyOnlineCVDataModel.Context.tt
真的
真的
MyOnlineCVDataModel.tt
真的
真的
MyOnlineCVDataModel.edmx
MyOnlineCVDataModel.tt
全模脱模发生器
MyOnlineCVDataModel.Designer.cs
MyOnlineCVDataModel.edmx
文本模板文件生成器
MyOnlineCVDataModel.Context.cs
MyOnlineCVDataModel.edmx
文本模板文件生成器
MyOnlineCVDataModel.edmx
MyOnlineCVDataModel.cs
6.4.4
6.2.0
这个构建有时已经工作了,但是一推它就停止工作了。我没有更改任何后端文件。我迷路了
编辑
以下是project 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>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.4.4" targetFramework="net472" />
</packages>
您在这里使用4.7.2框架构建项目,但在yml中您引用的是.Net核心框架。这可能是问题所在吗?最后,为了解决问题,我做了以下操作:
我卸载了每个实体框架nuget。
我删除了packages.config,并在.csproj中删除了以下内容:
<ItemGroup>
<PackageReference Include="EntityFramework">
<Version>6.4.4</Version>
</PackageReference>
<PackageReference Include="EntityFramework.fr">
<Version>6.2.0</Version>
</PackageReference>
</ItemGroup>
6.4.4
6.2.0
我重新安装了Entity Framework,下面是新的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>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.4.4" targetFramework="net472" />
</packages>
以及.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')" />
...
...
此项目正在引用此计算机上缺少的NuGet程序包。使用NuGet软件包还原选项下载它们。有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=322105. 缺少的文件是:{0}。
然后我承诺使用git,管道工作正常
请注意,管道中的步骤
run:nuget restore MyOnlineCV.sln
非常重要。如果没有它,就会出现错误。您可以为您的项目/解决方案显示packages.config
吗?我添加了file@Dyanek您是否看到在Restore numget packages
步骤中还原的包?您是否尝试过删除packages.config
文件并重新创建它?看起来你在使用GitHub操作,而不是Azure管道进行构建。我不这么认为。事实上,我的解决方案的主要项目是使用.Net核心框架。EF6的第二个项目使用4.7.2框架