Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [2.0.14] - 2022-01-14

Integration:

- Remove package version checking.

## [2.0.13] - 2022-01-12

Integration:

- Fixed wrong path to analyzers in generated projects when using external packages.
- Fixed selective project generation not creating Analyzer/LangVersion nodes.
- Fixed asmdef references with Player projects.

Documentation:

- Added new documentation including ToC, overview, how to use and images.
  • Loading branch information
Unity Technologies committed Jan 14, 2022
1 parent 1543604 commit fa2de33
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 101 deletions.
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Code Editor Package for Visual Studio

## [2.0.14] - 2022-01-14

Integration:

- Remove package version checking.


## [2.0.13] - 2022-01-12

Integration:

- Fixed wrong path to analyzers in generated projects when using external packages.
- Fixed selective project generation not creating Analyzer/LangVersion nodes.
- Fixed asmdef references with Player projects.

Documentation:

- Added new documentation including ToC, overview, how to use and images.

## [2.0.12] - 2021-10-20

Integration:
Expand All @@ -8,7 +27,6 @@ Integration:
- Only check package version once per Unity session.
- Improved support for Visual Studio For Mac 2022.


## [2.0.11] - 2021-07-01

Integration:
Expand All @@ -20,7 +38,6 @@ Project generation:

- Use absolute paths for Analyzers and rulesets.


## [2.0.10] - 2021-06-10

Project generation:
Expand Down
Binary file added Documentation~/Images/external-tools-tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Documentation~/TableOfContents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* [About Visual Studio Editor](index.md)
* [Using the Visual Studio Editor package](using-visual-studio-editor.md)
28 changes: 28 additions & 0 deletions Documentation~/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Code Editor Package for Visual Studio

## About Visual Studio Editor

The Visual Studio Editor package provides the Unity Editor with support for Unity-specific features from the [Visual Studio Tools for Unity](https://docs.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/visual-studio-tools-for-unity) extension in [Visual Studio](https://visualstudio.microsoft.com/) and [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/). These include IntelliSense auto-complete suggestions, C# editing, and debugging.

## Installation

This package is a built-in package and installed by default.

**Note**: If you’re using a version of the Unity Editor before 2019.4, you’ll need to install this package through the package manager.

## Requirements

This version of the Visual Studio Editor package is compatible with the following versions of the Unity Editor:

* 2019.4 and later

To use this package, you must have the following third-party products installed:

* **On Windows**: Visual Studio 2019 version 16.9 or newer with Visual Studio Tools for Unity 4.0.9 or newer.
* **On macOS**: Visual Studio for Mac 2019 version 8.9 or newer with Visual Studio Tools for Unity 2.0.9 or newer.

For more information about using Visual Studio with Unity, see [Microsoft’s Visual Studio Tools for Unity documentation](https://docs.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/visual-studio-tools-for-unity).

## Submitting issues

This package is maintained by Microsoft and Unity. Submit issues directly from Visual Studio and Visual Studio for Mac from the **Help** > **Submit Feedback** > **Report a Problem** menu. Unity will make this package accessible to the public on GitHub in the future.
23 changes: 23 additions & 0 deletions Documentation~/using-visual-studio-editor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Using the Visual Studio Editor package

To use the package, go to **Edit** > **Preferences** > **External Tools** > **External Script Editor** and select the version of **Visual Studio** you have installed. When you select this option, the window reloads and displays settings that control production of .csproj files.

![External Tools tab in the Preferences window](Images/external-tools-tab.png)

## Generate .csproj files

Each setting in the table below enables or disables the production of .csproj files for a different type of package.When you click **Regenerate project files**, Unity updates the existing .csproj files and creates the necessary new ones based on the settings you choose.


These settings control whether to generate .csproj files for any installed packages. For more information on how to install packages, see [Adding and removing packages](https://docs.unity3d.com/Manual/upm-ui-actions.html).

| **Property** | **Description** |
|---|---|
| **Embedded packages** | Any package that appears under your project’s Packages folder is an embedded package. An embedded package is not necessarily built-in; you can create your own packages and embed them inside your project. This setting is enabled by default.<br/><br/>For more information on embedded packages, see [Embedded dependencies](https://docs.unity3d.com/Manual/upm-embed.html). |
| **Local packages** | Any package that you install from a local repository stored on your machine, but from outside of your Unity project. This setting is enabled by default. |
| **Registry packages** | Any package that you install from either the official Unity registry or a custom registry. Packages in the Unity registry are available to install directly from the Package Manager. For more information about the Unity package registry, see The Package Registry section of the [Unity Package Manager documentation](https://docs.unity3d.com/Packages/[email protected]/manual/index.html#PackManRegistry). <br/><br/>For information on how to create and use custom registries in addition to the Unity registry, see [Scoped package registries](https://docs.unity3d.com/Manual/upm-scoped.html). |
| **Git packages** | Any package you install directly from a Git repository using a URL. |
| **Built-in packages** | Any package that is already installed as part of the default Unity installation. |
| **Tarball packages** | Any package you install from a GZip tarball archive on the local machine, outside of your Unity project. |
| **Unknown packages** | Any package which Unity cannot determine an origin for. This could be because the package doesn’t list its origin, or that Unity doesn’t recognize the origin listed. |
| **Player projects** | For each player project, generate an additional .csproj file named ‘originalProjectName.Player.csproj’. This allows different project types to have their code included in Visual Studio’s systems, such as assembly definitions or testing suites. |
3 changes: 2 additions & 1 deletion Editor/COMIntegration/COMIntegration~/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.15)

project(com)
set(SOURCES
Expand All @@ -10,4 +10,5 @@ set(SOURCES
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wall")
add_executable(COMIntegration ${SOURCES})
set_property(TARGET COMIntegration PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
target_link_libraries(COMIntegration Shlwapi.lib)
Binary file modified Editor/COMIntegration/Release/COMIntegration.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions Editor/FileUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ internal static bool IsFileInProjectRootDirectory(string fileName)
return relative == Path.GetFileName(relative);
}

public static string MakeAbsolutePath(this string path, string projectDirectory)
public static string MakeAbsolutePath(this string path)
{
if (string.IsNullOrEmpty(path)) { return string.Empty; }
return Path.IsPathRooted(path) ? path : Path.Combine(projectDirectory, path);
return Path.IsPathRooted(path) ? path : Path.GetFullPath(path);
}

// returns null if outside of the project scope
Expand Down
14 changes: 7 additions & 7 deletions Editor/Plugins/AppleEventIntegration.bundle/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>19H1217</string>
<string>19G2021</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -27,19 +27,19 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>12D4e</string>
<string>12B45b</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>11.1</string>
<string>11.0</string>
<key>DTSDKBuild</key>
<string>20C63</string>
<string>20A2408</string>
<key>DTSDKName</key>
<string>macosx11.1</string>
<string>macosx11.0</string>
<key>DTXcode</key>
<string>1240</string>
<string>1220</string>
<key>DTXcodeBuild</key>
<string>12D4e</string>
<string>12B45b</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>NSHumanReadableCopyright</key>
Expand Down
Binary file not shown.
27 changes: 18 additions & 9 deletions Editor/ProjectGeneration/ProjectGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public bool SyncIfNeeded(IEnumerable<string> affectedFiles, IEnumerable<string>
{
using (solutionSyncMarker.Auto())
{
// We need the exact VS version/capabilities to tweak project generation (analyzers/langversion)
RefreshCurrentInstallation();

SetupProjectSupportedExtensions();

// See https://devblogs.microsoft.com/setup/configure-visual-studio-across-your-organization-with-vsconfig/
Expand Down Expand Up @@ -527,9 +530,12 @@ private string ProjectText(Assembly assembly,
projectBuilder.Append(" <ItemGroup>").Append(k_WindowsNewline);
foreach (var reference in assembly.assemblyReferences.Where(i => i.sourceFiles.Any(ShouldFileBePartOfSolution)))
{
projectBuilder.Append(" <ProjectReference Include=\"").Append(reference.name).Append(GetProjectExtension()).Append("\">").Append(k_WindowsNewline);
projectBuilder.Append(" <Project>{").Append(ProjectGuid(reference)).Append("}</Project>").Append(k_WindowsNewline);
projectBuilder.Append(" <Name>").Append(reference.name).Append("</Name>").Append(k_WindowsNewline);
// If the current assembly is a Player project, we want to project-reference the corresponding Player project
var referenceName = m_AssemblyNameProvider.GetAssemblyName(assembly.outputPath, reference.name);

projectBuilder.Append(" <ProjectReference Include=\"").Append(referenceName).Append(GetProjectExtension()).Append("\">").Append(k_WindowsNewline);
projectBuilder.Append(" <Project>{").Append(ProjectGuid(referenceName)).Append("}</Project>").Append(k_WindowsNewline);
projectBuilder.Append(" <Name>").Append(referenceName).Append("</Name>").Append(k_WindowsNewline);
projectBuilder.Append(" </ProjectReference>").Append(k_WindowsNewline);
}

Expand Down Expand Up @@ -741,16 +747,16 @@ private string GetProjectHeader(ProjectProperties properties)
if (!string.IsNullOrEmpty(properties.RulesetPath))
{
lines.Add(@" <PropertyGroup>");
lines.Add($" <CodeAnalysisRuleSet>{properties.RulesetPath.MakeAbsolutePath(ProjectDirectory).NormalizePathSeparators()}</CodeAnalysisRuleSet>");
lines.Add($" <CodeAnalysisRuleSet>{properties.RulesetPath.MakeAbsolutePath().NormalizePathSeparators()}</CodeAnalysisRuleSet>");
lines.Add(@" </PropertyGroup>");
}

if (properties.Analyzers.Any())
{
lines.Add(@" <ItemGroup>");
foreach (var analyzer in properties.Analyzers)
foreach (var analyzer in properties.Analyzers.Distinct())
{
lines.Add($@" <Analyzer Include=""{analyzer.MakeAbsolutePath(ProjectDirectory).NormalizePathSeparators()}"" />");
lines.Add($@" <Analyzer Include=""{analyzer.MakeAbsolutePath().NormalizePathSeparators()}"" />");
}
lines.Add(@" </ItemGroup>");
}
Expand Down Expand Up @@ -948,11 +954,14 @@ static string GetProjectExtension()
return ".csproj";
}

private string ProjectGuid(string assemblyName)
{
return m_GUIDGenerator.ProjectGuid(m_ProjectName, assemblyName);
}

private string ProjectGuid(Assembly assembly)
{
return m_GUIDGenerator.ProjectGuid(
m_ProjectName,
m_AssemblyNameProvider.GetAssemblyName(assembly.outputPath, assembly.name));
return ProjectGuid(m_AssemblyNameProvider.GetAssemblyName(assembly.outputPath, assembly.name));
}

private string SolutionGuid(Assembly assembly)
Expand Down
31 changes: 0 additions & 31 deletions Editor/SessionSettings.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Editor/SessionSettings.cs.meta

This file was deleted.

34 changes: 0 additions & 34 deletions Editor/VisualStudioIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using Microsoft.Unity.VisualStudio.Editor.Messaging;
using Microsoft.Unity.VisualStudio.Editor.Testing;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEngine;
using MessageType = Microsoft.Unity.VisualStudio.Editor.Messaging.MessageType;

Expand All @@ -34,16 +32,11 @@ class Client
private static readonly object _incomingLock = new object();
private static readonly object _clientsLock = new object();

private static ListRequest _listRequest;

static VisualStudioIntegration()
{
if (!VisualStudioEditor.IsEnabled)
return;

if (!SessionSettings.PackageVersionChecked)
_listRequest = UnityEditor.PackageManager.Client.List();

RunOnceOnUpdate(() =>
{
// Despite using ReuseAddress|!ExclusiveAddressUse, we can fail here:
Expand Down Expand Up @@ -134,35 +127,8 @@ private static void ReceiveMessage(object sender, MessageEventArgs args)
OnMessage(args.Message);
}

private static void HandleListRequestCompletion()
{
const string packageName = "com.unity.ide.visualstudio";

if (_listRequest.Status == StatusCode.Success)
{
var package = _listRequest.Result.FirstOrDefault(p => p.name == packageName);

if (package != null
&& Version.TryParse(package.version, out var packageVersion)
&& Version.TryParse(package.versions.latest, out var latestVersion)
&& packageVersion < latestVersion)
{
Debug.LogWarning($"Visual Studio Editor Package version {package.versions.latest} is available, we strongly encourage you to update from the Unity Package Manager for a better Visual Studio integration");
}

SessionSettings.PackageVersionChecked = true;
}

_listRequest = null;
}

private static void OnUpdate()
{
if (_listRequest != null && _listRequest.IsCompleted)
{
HandleListRequestCompletion();
}

lock (_incomingLock)
{
while (_incoming.Count > 0)
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"name": "com.unity.ide.visualstudio",
"displayName": "Visual Studio Editor",
"description": "Code editor integration for supporting Visual Studio as code editor for unity. Adds support for generating csproj files for intellisense purposes, auto discovery of installations, etc.",
"version": "2.0.12",
"version": "2.0.14",
"unity": "2019.4",
"unityRelease": "25f1",
"dependencies": {
"com.unity.test-framework": "1.1.9"
},
"relatedPackages": {
"com.unity.ide.visualstudio.tests": "2.0.12"
"com.unity.ide.visualstudio.tests": "2.0.14"
},
"upmCi": {
"footprint": "bccd4d0383df110ebef0c62f85b5ac7cb9464de3"
"footprint": "8aa1049966a0586c636698ec81d764940b1dbe44"
},
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/com.unity.ide.visualstudio.git",
"type": "git",
"revision": "8d436ff053b9c59677b5e9799208143553cd02d9"
"revision": "f1e8af5df9e2507088a8622d173c9a7d5a03a882"
}
}

0 comments on commit fa2de33

Please sign in to comment.