我知道这个问题已经有无数人问过了。但是,我没有找到任何适合我的解决方案。
我有一个 .NET 网站项目,我使用的是 Entity Framework 6。
在本地,项目没有问题,一切正常。但是,当我将它推送到 GitHub 上的主分支以便将其部署到我的 Azure 网站时,会显示以下消息:
这是我的 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
它发生在“使用 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>
构建有时已经工作,但一推后它就停止工作。我没有更改任何后端文件。我迷路了
这是项目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>
答案 0 :(得分:1)
您在此处使用 4.7.2 框架构建项目,但在 yml 中您引用的是 .Net Core 框架。这可能是问题吗?
答案 1 :(得分:0)
最后为了解决问题,我这样做了: 我卸载了每个实体框架 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>
我重新安装了实体框架,这是新的packages.config:
<?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')" />
然后我承诺使用 git 并且管道正常工作。
请注意,管道中的步骤 run: nuget restore MyOnlineCV.sln
是必不可少的。没有它会出现错误。