Tôi không tìm thấy project.json trong studio trực quan 2017 RC. Điều này đã được gỡ bỏ trong phiên bản này hoặc tôi đang thiếu một cái gì đó? Làm cách nào để lưu trữ danh sách phụ thuộc ngay bây giờ nếu nó bị xóa?project.json Không tìm thấy trong Visual Studio 2017 RC Solution Explorer
18
A
Trả lời
37
Về sau, .Net Core sẽ dựa trên msbuild, có nghĩa là nó sẽ sử dụng * .csproj thay vì project.json. Tham chiếu gói bây giờ cũng được lưu trữ trong tệp * .csproj.
Để biết thêm thông tin, hãy đọc Announcing .NET Core Tools MSBuild “alpha” on the .NET Blog và High level overview of changes in CLI Preview 3 in .NET Documentation.
Ví dụ, nếu bạn đã có trong project.json của bạn:
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Newtonsoft.Json": "9.0.1"
}
Bây giờ bạn sẽ có * csproj chứa:
<PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Sdk">
<Version>1.0.0-alpha-20161104-2</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>9.0.1</Version>
</PackageReference>
3
Hãy tham khảo Với liên kết
https://docs.microsoft.com/en-us/dotnet/core/tools/project-json-to-csproj
Project.json
{
"buildOptions": {
"warningsAsErrors": true,
"nowarn": ["CS0168", "CS0219"],
"xmlDoc": true,
"preserveCompilationContext": true,
"outputName": "Different.AssemblyName",
"debugType": "portable",
"allowUnsafe": true,
"define": ["TEST", "OTHERCONDITION"]
}
}
Solution-> Right Click -> Edit Project.csporj
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS0168;CS0219</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Different.AssemblyName</AssemblyName>
<DebugType>portable</DebugType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);TEST;OTHERCONDITION</DefineConstants>
</PropertyGroup>
3
Trong Solution Explorer:
- Kích chuột phải vào Dự án
- Chọn Chỉnh sửa (YourProjectNameHere) .csproj
Cửa sổ sẽ xuất hiện cho phép bạn xem phiên bản XML của .csproj. Các phụ thuộc sẽ được liệt kê ở đây trong mô tả PackageReference.
Các vấn đề liên quan
- 1. Visual Studio Solution Explorer Khóa
- 2. Copypaste không hoạt động trong Visual Studio Solution Explorer
- 3. Visual Studio 2017 - Đội Explorer xây dựng 'Trang không tìm thấy'
- 4. Visual Studio 2017 không thể tìm thấy windows.h
- 5. Cách di chuyển tab "Solution Explorer" trong Visual Studio
- 6. Visual Studio Solution Explorer/Navigator Biểu tượng Ý nghĩa
- 7. Visual Studio "Search Solution Explorer" bị vô hiệu hóa
- 8. Thư mục thực trong Visual Solution Explorer?
- 9. lỗi MSB1001: Unknown switch - Visual Studio 2017 RC
- 10. Giải pháp hạ cấp từ Visual Studio 2017 RC sang Visual Studio 2015
- 11. Visual Studio 2017 - không thể tìm thấy Visual C++ Windows Forms
- 12. Visual studio project.json không có phần thời gian chạy
- 13. Nút làm mới trong Visual Studio Solution Explorer không hoạt động
- 14. Visual Studio 2017 RC Cách chỉ định Tùy chọn xuất bản trong tệp csproj
- 15. Visual Studio 2010: Solution Explorer không hiển thị cấu trúc thư mục dự án
- 16. Ứng dụng bảng điều khiển không được tìm thấy trong Visual Studio 2017 cho C#
- 17. Không thể tìm thấy điểm vào có tên '?' trong DLL 'PkgdefMgmt.dll' trên Visual Studio 2017 (VS 2017)
- 18. Không thể cài đặt exenstions và cập nhật cho Visual Studio 2017 RC (15.0.26014.0)
- 19. Visual Studio Solution Explorer không hiển thị các tệp và thư mục
- 20. Không thể thêm tham chiếu Intellisense JavaScript toàn cầu vào Visual Studio 2017 RC
- 21. Không thể nhận được các bài kiểm tra XUnit làm việc với Visual Studio 2017 RC
- 22. Visual Studio 2017 Hoạt động thiết lập RC không thành công
- 23. Visual Studio 2017 RC lỗi cài đặt 0x80131500 Không thể deserialize gói
- 24. Bật SSL trong Visual Studio 2017
- 25. Visual Studio - Tệp hiện tại trong Solution Explorer - Làm cho nó tối hơn?
- 26. Visual Studio 2017 Collapsing Regions
- 27. Visual Studio 2017 Bật SSL
- 28. Làm thế nào để bạn sử dụng npm trong Visual studio 2017 mà không có tệp project.json?
- 29. Visual Studio 2017 HRESULT: 0x80004004
- 30. Bật RyuJIT trong Visual Studio 2015 RC
Cảm ơn bạn, đó là hữu ích – aspxsushil
Tôi chắc chắn có một lý do hợp lệ để chuyển từ project.json sang * .csproj, nhưng từ nơi tôi đang ngồi ... project.json dễ hiểu hơn gấp 10 lần trong nháy mắt từ góc độ mã hóa ... –
@KevinFrancis Hãy nhớ rằng đoạn csproj tôi đã trình bày ở đây đã lỗi thời. Bạn không còn tham chiếu đến 'Microsoft.NETCore.App', SDK chỉ là một thuộc tính duy nhất trên phần tử gốc và các phiên bản gói có thể được chỉ định bằng cách sử dụng một thuộc tính. Theo ý kiến của tôi, ngay cả khi bạn không thích cú pháp XML, sức mạnh gia tăng và sự hợp nhất với tất cả các loại dự án khác cũng đáng giá. – svick