1

I am using this command postbuild in .net 4.6.1 web api project.

$(NSwagExe) aspnetcore2swagger "/assembly:$(TargetPath)" "/output:$(OutputPath)swagger.json"

However it's failing on 2 places, first one is,

1>System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The physical path is 'C:\Users\XXXX\source\Workspaces\Information Systems\SOLUTION\SOLUTION.Api\bin\x64\Debug\

appsettings.json file is in same directory as Startup.cs. And this is how I am getting it

  public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json")

Now to move forward, just to make it work, if I hard code path it works but I get this error then,

5>System.Runtime.Serialization.SerializationException: Type 'StructureMap.StructureMapConfigurationException' in Assembly 'StructureMap, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Here is one of places in startup where I am using this structuremap,

   Start.LogicContainer.Configure(x => x.For<DBContext>().Use<DBContext>()
                .Ctor<string>("nameOrConnectionString").Is(Configuration.GetConnectionString("DefaultConnection")));

All I want is to generate swagger.json file on each build.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.