I have a console application that I've been developing and I'm just about ready to publish it for consumption.
However, there's a file that the app needs to reference (a couple files actually) and I'd like to try to include these either during install logic or via an outside process. Here's the situation:
The application fires off a load test based on some criteria the user chooses. The load test is defined by a .loadtest file which is created outside of this project.
So what I would like for the installer to do is contain the .loadtest files and just shove them in a default directory that the project can reference.
I can't figure out how to add this specific file as a pre-requisite or anything though, in the publish wizard. Any ideas?
When you add a file to the solution, it does not automatically get attached as part of the build in some cases. If you right click the file in your solution explorer and select "Properties", change the build action to "Content". This will ensure that VS includes the file as part of the build/publish and places it in the output directory of the build process.
Related
I have a .webtest that I am intending to use to load test uploading a file to a website. I am using the webtest framework that is built into visual studio with the intention of running my larger scale tests from azure.
I created a new webtest and recorded the steps, including the file upload. This all recorded correctly, but the problem is that the File Upload Parameter was just recorded the filename (not the bytes). This means that the test needs to have access to the file that will be uploaded during running.
I also added the file to the project and set it to be content.
The problem is that the file isn't getting copied over during running. I found a blog post https://blogs.msdn.microsoft.com/edglas/2008/08/05/how-to-upload-a-file-in-a-web-test/ which appears to answer my question but the visual studio ui has changed and the option is no longer available.
I cannot use an absolute url c:\files\filename.docx because i need to run this from azure.
I also cannot post the file somewhere on the internet because it has to be a path, not a url.
I have posted a queston to the blog post, but it doesn't seem very active and am really at a lose for where to go from here.
TIA,
-Logan
The "Deployment" functionality shown in the last screenshot of Ed Glass's blog is now in the .testsettings files of the solution. (The blog shows a window with a "localtestrun.testrunconfig" file.) If you have more than one .testsettings file then ensure that the context menu of the correct file has the "Active load and web test settings" ticked.
In the deployment section of the .testsettings file, tick "Enable deployment" and add the directory or file(s) to be used in the tests. After running a test you should then find that the items have been copied into a subdirectory of the TestResults\{{name+date+time}} directory, as described in the blog.
New .testsettings files can be added to a solution as follows. From the context menu of the solution (the topmost item in Solution Explorer), select Add => New item => Test settings (from the left hand side of the "Add new item" window), then fill in the forms. New files can also be created via the "Save as" button in the test settings editor, but this requires a file to already be open.
When creating new .testsettings files I recommend changing the "Name" field in the "General" section to match the filename. Not doing so (after using "Save as") has left me confused because two or more files appear to have the same name. I normally have up to three .testsettings file in a solution: One for local use when developing tests. Another (often named "cloud" or "vsts") configured for cloud load testing with VSTS. The third version (often named "agent" or "remote") for use with controllers and agents.
I am using Advanced Installer with Visual Studio 2010.
I managed to create an .aip project, but when I want to add the files from the relevant VS projects, I have to choose the exact location of these files.
I want to use more then one build configuration so I can use config transforms to change my .config files depend on the build configuration I choose.
This is a problem for me because when I compile in Debug the .exe & .dll files goes to bin\Debug, but when I compile in, lets say, Staging these files goes to bin\Staging.
How can I get Advanced Installer to get the right files, meaning get them from the target folder of the build configuration I chosen?
Advanced Installer does not support this by default, but with a little bit of tweaking you can get this working. Let me explain how:
the first requirement is to have your output folders generated by VS in the same parent folder, as you have them both placed in "bin\".
now you need to open your project in Advanced Installer GUI and do the following:
create two builds in Media page, called Debug and Staging
create a property called "Configuration" or what name would you like, from Install Parameters page
in the New Property dialog you will have options to set per-build values for your property. Set them to "Debug" and "Staging", i.e. the names of the folders created by VS
now go to File -> Options -> Path Variables and define a new path variable with your full path for the debug/staging, the one you current have in the project.
from the Home tab, in the toolbar, use the "Convert Paths" wizard and then save the project.
Now, it comes the tricky part, you will need to edit the project file in a text editor, like Notepad++, capable of saving the file in UTF-8 format. Once you open the file look for this XML node:
<COMPONENT cid="caphyon.advinst.msicomp.AppPathsComponent">
<ROW Name="BIN_DIR" Path="<your path>\bin\Debug" Type="2" Content="0"/>
You might have multiple variables here if you are already using this feature. You need to edit the value and replace "Debug" with "[|Configuration]".
Now you can save and build the project and it should pickup the correct files for each of the two builds.
Usually, visual studio puts output files to bin/debug or bin/release.
When solution contains a large number of projects its not easy to modify each project output manually.
Also edits in csproj files no desirable, because some of them is shared between solutions..
My questions: Is anybody knows a tool, which can quickly configure output path ?
UPDATE: my problem solved by TFS Build
Presumably you have at least one project in each solution that is unique to that solution. In the Post-Build event of that, copy the contents of each project's output to the required location.
We often to this using a batch file. It's crude but effective. In our project that's unique to the solution we create a Release.bat file. This contains a number of file copies to copy all of the required components from the various output directories of the other projects. You can then just run the batch file in the post build event. We usually copy everything to a "Latest Release" fodler when the solution is built. If this becomes a proper release we will rename the Latest Release folder to the actual release number.
If you have multiple build configurations, or even just use the Debug and Release configurations, you can use an If statement in the Post-Build event to decide which batch file to run. So you could create a Debug.bat, Release.bat etc which do what you need. It can be tedious to set them up and get them working correctly at first, but they are very useful once fully implemented.
Customize your project using the msbuild properties which you can do if you follow these steps:
Go to the solution explorer and unload one project by right clicking on it and select Unload Project.
Then right click again on the unloaded project and select Edit Project. This will open the XML definition of your project, and you will have intellisense for the layout which will help you perform the next steps.
In the visual studio editor find the first PropertyGroup tag and add these lines near or at the end of the closing PropertyGroup tag:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<BuildDirectory Condition="$(BuildDirectory) =='' or $(BuildDirectory) == '*Undefined*'">$(SolutionDir)\build\</BuildDirectory>
The above SolutionDir is defined in msbuild properties which you can obtain using this answer: msbuild script using solution information and also check out the well known msbuild properties here
The next step is to find the OutputPath tag for each configuration and edit it like this:
<OutputPath>$(BuildDirectory)\x86\AutomatedDebug\</OutputPath>
The example above assumes you have a configuration named AutomatedDebug with destination platform x86.
The output will be
x:\projects\whereever-your-solution-is\build\x86\AutomatedDebug\
Repeat for each project.
To unload more than one project, collapse all projects in the solution explorer and shift click or ctrl click to select all or some projects, then right click on the selected group to unload, unfortunately you cannot do this for editing, at least in visual studio 2010.
I am the first to admit that this is somewhat cumbersome to do for existing projects, but you could easily create a visual studio project template that has these settings changed so that new projects will use a more convenient default output directory.
You cannot edit the output directory directly in visual studio because the project properties editor escapes any $() enclosed text.
Also you could only modify the OutputPath using the name of a system environment variable enclosed in $(). This last option is to enable a global output directory.
If you build any single project modified in this way using msbuild directly in the commandline the output directory will be created one directory above from where you ran msbuild
..\build\x86\AutomatedDebug
If you are in a team, you should warn them not to edit the output directory directly by hand, as this action will overwrite any customization.
Hope this info is useful.
Greetings.
I am using advanced version of Visual Studio 2010 and using database projects. There's a feature of exporting database schema as partial project (which creates *.files output file), but it is triggered manually by the developer (you need to right-click on the project and select Export as partial project). I would like to automatize this process, meaning that the output file is created each time I modify the database, I build it OR I close the solution.
I tried creating a macro, which executes a DTE command Project.VSDBExportAsPartialProject, but sometimes it fails with an exception AND it shows a Save as dialog box, which I would like to avoid. Maybe the idea is to add it to the post-build event, but I don't know how to execute DTE commands from there.
To sum up, all I need is to automatically refresh the *.files output file located in fixed path without any user interactions.
Is it possible?
I'm using Visual Studio 2008 and would like to create a sort of container project that holds a number of DLL's that must be installed with a solution. I want them to be in a separate project so that they can be easily attached to a solution as a group.
I created an empty project call TEST, added my DLL's to it with a Build Action of "Content", and set them to "Copy Always". That all works exactly as I want. The problem is that if I set the TEST project Output Type to "Console Application" or "Windows Application" that it won't build because there's no entry point. If I set the Output Type to "Class Library", it builds but I end up with an extra TEST.DLL file that I don't really want.
Is there anyway to sort of set the Output Type to "none"? I want the build actions to take place (so my DLL's get copied) but I don't want the dummy class assembly created. Any ideas?
Thanks!
Assumptions for the following step-by-step guide:
Let's assume that you have a solution with two projects:
Main: your main (start-up) project.
BundledDLLs: a library project which contains the .dlls that should end up in the main project's output directory.
Step-by-step guide:
The easiest way to achieve your goal inside Visual Studio is probably the following:
Add all .dlls to BundledDLLs and set their Copy to output directory to Copy if newer.
This is done in the Project Explorer and the Properties windows.
Configure BundledDLLs's output directory to be identical to Main's output directory.
This can be done in the Build tab of BundledDLL's Project Properties page. Enter something like the following in the Output Path textbox:
..\Main\bin\Debug
Set up BundledDLLs as a dependency of Main.
Do not add BundledDLLs as a project reference to Main, as you usually might; instead, use the Project Dependencies dialog to . This will tell the build tool that whenever Main is built, BundledDLLs needs to be built first.
Do this by right-clicking on the Main project node to open the context menu; select Project dependencies... from there. In the now opened dialog, first select Main from the drop-down list; then check BundledDLLs in the project list below. BundledDLLs is now registered as a dependency of Main.
P.S.: One disadvantage of not having an explicit assembly reference in Main is that some tooling might not recognise the dependency. For example, ClickOnce deployment might not work properly.
Add a post-build event to BundledDLLs that deletes the superfluous BundledDLLs.dll.
As you said, you don't want, and don't need, the dummy output generated when BundledDLLs is built. So add a post-build event that simply deletes this .dll once it's been created.
Open the Build events tab in BundledDLLs's Project Properties page, and enter something like the following in the post-build textbox:
DEL "$(TargetDir)\$(TargetName).*"
(In case you wondered: The reason why you didn't add this project as a project reference to Main earlier is because if you had done so, Main would be looking for BundledDLLs.dll, which it wouldn't be able to find since you don't actually want such a file to be generated.)
P.S.: One disadvantage of adding such a post-build step is that it might interfere with incremental builds. If your project keeps getting recompiled from scratch after this, you might be better off removing the post-build step and living with the extra BundledDLLs.dll in your solution's output directory.
Another option is to use a makefile project, which doesn't require you to build/link anything.
In your project properties (right click property in solution explorer and click "Properties"), under "Configuration Properties" and then under "General", choose "Makefile" from the "Configuration Type" drop-down menu. The build output will include the warning "The property 'NMakeBuildCommandLine' doesn't exist...Skipping" but the build will succeed without building any dll/exe/etc.
While other answers here may better address your specific need, specifying a makefile more directly answers the question title "Possible to create Visual Studio project with Output Type of none?" I hope this is useful for people who google something to that effect and land here.
Credit goes to Xeek in the #winapi freenode irc channel for sharing this tip.
Instead of putting them in a project, you can put the files in a Solution Folder. One of your projects can have a build action that does the copying, but since they won't be in a project, they won't try to "build".