Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
864 views
in Technique[技术] by (71.8m points)

c# - Get package directory task failed unexpectedly

I was working with some examples about "Constructors" and I made this example on Visual Studio:

using System;
using System.Reflection.Metadata.Ecma335;

namespace Classes
{
    class Program
    {
        static void Main(string[] args)
        {
            var customer = new Customer(1, "John");
            Console.WriteLine(customer.Id);
            Console.WriteLine(customer.Name);
        }
    }
    public class Customer
    {
        public int Id;
        public string Name;

        public Customer()
        {

        }

        public Customer(int id)
        {
            this.Id = id;
        }

        public Customer(int id, string name)
        {
            this.Id = id;
            this.Name = name;
        }
    }
}

But when I try to run the code, I get this message:

The "GetPackageDirectory" task failed unexpectedly.

So what is going wrong here? Why am I facing this issue?

I would really appreciate any idea or suggestion from you guys.

Thanks in advance.

question from:https://stackoverflow.com/questions/65863792/get-package-directory-task-failed-unexpectedly

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

u can try dotnet restore and dotnet clean in order. here's a link

edit--- also u can add those codes in ur package library

<PropertyGroup>
    <RestoreFallbackFolders>clear</RestoreFallbackFolders>
  </PropertyGroup>

it will clean up any old package or referances packages. dont worry,it will create them again after u build it ur project.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...