2

I read this article https://learn.microsoft.com/en-us/visualstudio/ide/develop-code-in-visual-studio-without-projects-or-solutions?view=vs-2019

It seems to indicate that you can now work in Visual Studio without .sln files.

I've had a lot of issues with .sln files while using git. So I was hoping to dispense with them. .csproj files generally are fine though.

Here is my .csproj file contents

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

</Project>

Here is my program.cs

using System;

namespace TestWithoutSln
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

I have tried setting the .csproj file as start up and I get the following 'Error NETSDK1004 Assets file 'C:\Users\Blah\Desktop\Working Repositories\Projects\Test\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.'

But I can't figure out how to run a package restore without the .csproj loaded. The Package Management Console has no projects listed.

after that how can I have one project reference another project?

Edit in Addition: I have tried dotnet restore from the Developer Command Prompt. I now have a new error when I run it after a successful build.

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
TheColonel26
  • 2,618
  • 7
  • 25
  • 50
  • Out of curiosity, what issues have you had with solution files? – ProgrammingLlama Jul 16 '19 at 03:03
  • 1
    I've had a lot of issues when trying to merge branches. The .sln gets updated a lot and I get conflicts. It always turns in to a mess, and it's contents are about 50% gibberish. The .csproj files on the other hand are pretty easy to deal with. – TheColonel26 Jul 16 '19 at 03:05
  • Possible duplicate of [Assets file project.assets.json not found. Run a NuGet package restore](https://stackoverflow.com/questions/48440223/assets-file-project-assets-json-not-found-run-a-nuget-package-restore) – Daniel Jul 16 '19 at 03:11

1 Answers1

1

you should simply navigate inside the folder where your .csproj file is located and to a

PS> dotnet restore
Daniel
  • 9,491
  • 12
  • 50
  • 66
  • 1
    now I get 'An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'System.Runtime, Version=4.2.1.0,' When I run it. FYI I am using a default .Net Core Hello World CLI program. – TheColonel26 Jul 17 '19 at 02:36
  • @TheColonel26 all i did was googling around and found https://github.com/Azure/azure-functions-vs-build-sdk/issues/160 maybe that helps. – Daniel Jul 17 '19 at 04:32