title: Why is `dotnet new webapi` creating a different project for me than other people?
body: <p>Hi I'm following instructions from a tutorial. Using <code>dotnet new webapi</code> I'm getting a different project than the lesson shows and from another person's computer which I tested this on. We get mostly the same files but I have one extra <code>WeatherForcast.cs</code> and instead of the <code>ValuesController.cs</code> I get <code>WeatherForcastController.cs</code> with completely different code in it that I'll post at the bottom.</p>
  
  <p>There are also some smaller differences in <code>Program.cs</code> and <code>Startup.cs</code> </p>
  
  <p>What accounts for this difference? How do I generate the files the way I'm trying, from the examples?</p>
  
  <h3>ANSWER : The answer is that it was defaulting to the .NET SDK 3.1 I have installed but this tutorial using .NET SDK 2.2. Running the command <code>dotnet new webapi --framework netcoreapp2.2</code> gives me the version of this webapi I'm looking for.</h3>
  
  <hr>
  
  <h3>My controller <code>WeatherForcastController.cs</code></h3>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.Extensions.Logging;
  
  namespace Testing.Controllers
  {
      [ApiController]
      [Route("[controller]")]
      public class WeatherForecastController : ControllerBase
      {
          private static readonly string[] Summaries = new[]
          {
              "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
          };
  
          private readonly ILogger&lt;WeatherForecastController&gt; _logger;
  
          public WeatherForecastController(ILogger&lt;WeatherForecastController&gt; logger)
          {
              _logger = logger;
          }
  
          [HttpGet]
          public IEnumerable&lt;WeatherForecast&gt; Get()
          {
              var rng = new Random();
              return Enumerable.Range(1, 5).Select(index =&gt; new WeatherForecast
              {
                  Date = DateTime.Now.AddDays(index),
                  TemperatureC = rng.Next(-20, 55),
                  Summary = Summaries[rng.Next(Summaries.Length)]
              })
              .ToArray();
          }
      }
  }
  
  </code></pre>
  
  <h3>Example &amp; other computer controller <code>ValuesController.cs</code></h3>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Mvc;
  
  namespace CretaceousPark.Controllers
  {
      [Route("api/[controller]")]
      [ApiController]
      public class ValuesController : ControllerBase
      {
          // GET api/values
          [HttpGet]
          public ActionResult&lt;IEnumerable&lt;string&gt;&gt; Get()
          {
              return new string[] { "value1", "value2" };
          }
  
          // GET api/values/5
          [HttpGet("{id}")]
          public ActionResult&lt;string&gt; Get(int id)
          {
              return "value";
          }
  
          // POST api/values
          [HttpPost]
          public void Post([FromBody] string value)
          {
          }
  
          // PUT api/values/5
          [HttpPut("{id}")]
          public void Put(int id, [FromBody] string value)
          {
          }
  
          // DELETE api/values/5
          [HttpDelete("{id}")]
          public void Delete(int id)
          {
          }
      }
  }
  
  </code></pre>