Swagger导出服务器 - 错误CS0103:当前上下文中不存在该名称

时间:2018-03-25 12:03:28

标签: asp.net-core swagger swagger-2.0 swagger-editor swagger-codegen

我有一个关于swagger的api定义,我正试图用它来生成一个.NET WebAPI服务器。

我可以导出一个aspnetcore项目但是当我尝试构建或加载项目时出现以下错误:

当我尝试在Visual Studio中打开时:

enter image description here

执行build.bat时,这是完整的错误:

PS D:\Documents\Development\swagger\server\aspnetcore-server> .\build.bat
  Restoring packages for D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj...
  Restoring packages for D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj...
  Restoring packages for D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj...
  Restoring packages for D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj...
  Restore completed in 179.1 ms for D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj.
  Restore completed in 532.37 ms for D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj.
  Restore completed in 597.91 ms for D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj.
  Generating MSBuild file D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\obj\IO.Swagger.csproj.nuget.g.props.
  Generating MSBuild file D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\obj\IO.Swagger.csproj.nuget.g.targets.
  Restore completed in 1.07 sec for D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj.
Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Models\MailIdentifier.cs(49,33): error CS0103: The name 'enterprise' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Enterprise.cs(73,33): error CS0103: The name 'connected' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Connection.cs(43,33): error CS0103: The name 'connected' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Enterprise.cs(79,33): error CS0103: The name 'pending' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Connection.cs(49,33): error CS0103: The name 'disconnected' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\MailIdentifier.cs(55,33): error CS0103: The name 'consumer' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Enterprise.cs(85,33): error CS0103: The name 'notConnected' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]

Build FAILED.

Models\MailIdentifier.cs(49,33): error CS0103: The name 'enterprise' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Enterprise.cs(73,33): error CS0103: The name 'connected' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Connection.cs(43,33): error CS0103: The name 'connected' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Enterprise.cs(79,33): error CS0103: The name 'pending' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Connection.cs(49,33): error CS0103: The name 'disconnected' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\MailIdentifier.cs(55,33): error CS0103: The name 'consumer' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
Models\Enterprise.cs(85,33): error CS0103: The name 'notConnected' does not exist in the current context [D:\Documents\Development\swagger\server\aspnetcore-server\src\IO.Swagger\IO.Swagger.csproj]
    0 Warning(s)
    7 Error(s)

Time Elapsed 00:00:03.08
Now, run the following to start the project: dotnet run -p src\IO.Swagger\IO.Swagger.csproj --launch-profile web.

PS D:\Documents\Development\swagger\server\aspnetcore-server>

.csproj文件

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <Description>IO.Swagger</Description>
    <Copyright>IO.Swagger</Copyright>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>IO.Swagger</AssemblyName>
    <PackageId>IO.Swagger</PackageId>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="wwwroot\"/>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3"/>
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.1.0"/>
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1"/>
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0"/>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1"/>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0"/>
  </ItemGroup>
</Project>

0 个答案:

没有答案