Visual Studio 2017 C++ Project Copy Text Files to Output Directory - copy

I have a number of *.txt files included in my Visual Studio 2017 C++ project (*.vcxproj). Does anyone know how to get Visual Studio to copy these files to the output directory?
I found a similar question for VS 2010, but that answer doesn't work in Visual Studio 2017.

In the *.vcxproj file, change:
<Text Include="Filename.txt" />
to:
<Content Include="Filename.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Then in the *.vcxproj.filters file, change:
<Text Include="Filename.txt">
<Filter>Resource Files</Filter>
</Text>
to:
<Content Include="Filename.txt">
<Filter>Resource Files</Filter>
</Content>

Update for 2019 users:
An easy way to do this is from the file's Property Pages (right-click on the file in Solution Explorer, then click Properties).
Under Configuration Properties > General, change Item Type to "Copy file." By default, this will create a copy of the file in the build destination directory. Once you hit Apply, a new property page called Copy File will appear on the left where you can customize this behavior.

In a VS2019 c++ console project it was just a litlle different:
<ItemGroup>
<None Include="Run.bat">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

Related

WebStorm equivalent folder configurations as VSCode ".vscode" folder?

I have a repository with prettier package installed. I have configured the repository in VSCode to be formatted by Prettier with each save action on any file.
I want to do the same thing in WebStorm without any pre-manual action. Because at the moment, if I open the repository with WebStorm, in order to get auto-format by prettier, I need to manually configure it within the settings of WebStorm.
In VSCode, I created the file: .vscode/settings.json:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
How can I make the same in WebStorm so I won't need to do it manually?
You can add prettier.xml like
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PrettierConfiguration">
<option name="myRunOnSave" value="true" />
<option name="myRunOnReformat" value="true" />
</component>
</project>
to the project .idea folder.
But the prettier package path is stored in workspace.xml that is huge and updated ofter... you can search for the "prettierjs.PrettierConfiguration.Package" key to see what this configuration looks like there

How can I add SSH.NET NuGet packages into my Azure Functions v2.0?

my Azure function is v2.
I have added <PackageReference Include="SSH.NET" Version="2016.1.0" /> into ItemGroup in function.proj.
However, #r "Renci.SshNet" is NOT working. #r "D:\home\site\wwwroot\bin\Renci.SshNet.dll" is NOT working either. Because there is no bin folder under wwwroot.
What is the normal way to include Renci.SshNet?
Regards,
Zhenyu
my function.proj screenshot
You can add bin folder under wwwroot and drag the dll to it by "Advanced tools(kudu)" under azure function "Platform features" tag.
First, click "kudu" (shown as below screenshot)
Then click "Debug console" --> "CMD" --> "site" --> "wwwroot" --> "New folder" and namd the folder as "bin".
Then drag the dll file to the bin folder and then you can use it by #r command(shown as below)
Update:
You can try to modify your function.proj as below:
<PackageReference Include="Renci.SshNet.Async" Version="1.4.0" />
And in your function use the command "using Renci.SshNet;".
And remove the #r line of Renci.SshNet you added before.
Please have a try.

Nuget Package Icon Not getting Displayed

I'm developing an Nuget Package. I have icon.png placed inside Images folder inside my package code. In my .csproj file I have added required tags related to icon. But still icon is not getting displayed. Instead default blue icon is displayed in Nuget.
Here is my .csproj file,
<PropertyGroup>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>
<ItemGroup>
<None Include="Images\icon.png" Pack="true" PackagePath=""/>
</ItemGroup>
Am I missing anything? please assist.
Currently, displaying the icon by using the <PackageIcon/> or <icon/> property on packages showed on NuGet in Visual Studio is not supported. You can preview your package icon in the upload preview in https://nuget.org
The tracking issue for supporting embedded icons in NuGet for Visual Studio is: https://github.com/NuGet/Home/issues/8189

How do I get Visual Studio 2015 RC to pick up the repositoryPath setting from my nuget.config?

We use a custom location for our packages folder which we specify in a nuget.config file in the same folder as our solution:
<settings>
<repositoryPath>..\..\lib\packages</repositoryPath>
</settings>
Visual Studio 2013 picks this up fine and the NuGet package manager installs packages into the specified folder, lists installed packages correctly, etc.
In Visual Studio 2015 RC the NuGet package manager pops up the "Some packages are missing from this solution, click here to restore" message and if I click the button it creates a new packages folder in the same folder as the solution rather than using the location specified in the nuget.config. Installing a completely new package also puts it into a packages folder under the solution folder rather than the specified one.
How do I get Visual Studio 2015 RC to respect the repository path specified in the nuget.config?
Make sure your nuget.config is configured like this:
<configuration>
<config>
<add key="repositoryPath" value="..\..\lib\packages" />
</config>
</configuration>
I filed this bug with NuGet: https://github.com/NuGet/Home/issues/626
A fix has been made but I'm not sure when it will be released.

How can I hide files from Solution Explorer by name in VS2015?

I am writing a website in VS2015 using the ASP.NET Preview template. Unfortunately, Dropbox has added a bunch of .dropbox.attr files in each folder of my project, which the Solution Explorer is displaying:
Note that I have not added them to the project manually, (they are not referenced in my Web.xproj,) and I do not have "Show All Files" selected. I have already added them to my .gitignore. There is no "Remove" option when selecting the file:
Lastly, I have tried adding them to my project.json's exclude section:
...
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc",
".dropbox.attr"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components",
".dropbox.attr"
]
...
Is there any way to get all files with this name to not appear in my Solution Explorer?
I'm not sure exactly of the interaction between VS2015 and the new project structure, so it could be a result of any of those factors.
You can modify the .xproj file of your project and add the following to exclude folders:
<ItemGroup>
<DnxInvisibleFolder Include="wwwroot\jspm_packages\" />
<DnxInvisibleFolder Include="wwwroot\node_modules\" />
<DnxInvisibleContent Include="wwwroot\tsd.json" />
</ItemGroup>
You can use DnxInvisibleFolder for folders and DnxInvisibleContent for files.
Some folders (like node_modules) have sometimes thousands of folders/files which seem to pose a major problem for VS2015 to scan and load.
In a DNX project in visual Studio 2015 the solution explorer does not use the project.json to determine what is shown. The "exclude" properties in project.json are used by dnx to determine which folders/files should be excluded from compilation or publishing but this does not affect Visual Studio's solution explorer.
Generally speaking "everything" is shown but that isn't exactly true as VS excludes certain folders (such as .git, .vs, artifacts, etc). It also adds back others (i.e. bower components is excluded by default from compilation but VS adds it back as a meta folder under dependencies). The "filter" for Solution Explorer is not exposed to the user so it can't be edited or changed by configuration file.
Your best bet would be to request via user voice that some method of configuration be added. Really the functionality is already there it just needs to be made customizable by the user.
With the latest Visual Studio you just need to right-click the folder/file and chose "Hide from Solution Explorer".
That will change the "xproj" this way like Corneliu wrote before:
<ItemGroup>
<DnxInvisibleFolder Include="wwwroot\" />
</ItemGroup>