Nuget post build event - adding files to path inside .nupkg - c#

I'm posting this here since I haven't been able to get any help from nuproj's github page.
I have some files I need to write to a specific path in my .nupkg file. After a successful build, I would like to place several files into a specific path (runtimes/win7-x64/native) instead of the default 'lib/net45' folder.
Right now, I have to open the .nupkg file (I use Nuget Package Explorer) and manually create the (runtimes/win7-x64/native) folder structure then add the appropriate files. Note - these files have to be in this specific path in order for them to work in my project.
Basically, how do I go about using nuproj to handle this for me and eliminate the need for me to do it manually? I've attached an image to better illustrate my question (the part in red is what I'm trying to automate).

You could edit the nuspec file and set the folder path for the target.
How to add a folder to a nuspec file
And then create the .nupkg file with the edited nuspec file in command line.
http://www.hanselman.com/blog/CreatingANuGetPackageIn7EasyStepsPlusUsingNuGetToIntegrateASPNETMVC3IntoExistingWebFormsApplications.aspx
And then you could add the command line to the post-build event.

Related

Send a solution as a single archive file

It's my first time sending a solution, so I have no experience with it.
The requirement is to send a solution as a single archive file containing only source code files.
I will quote for precision:
"Send a fully buildable single solution and source code files only, excluding all binaries".
What should I do?
Follow these steps -
From build menu select "Clean Solution". This will empty the bin folders
Delete all obj folders in all project folders. If you wish you can also remove bin folders, not mandatory though, as they should already be empty after step 1.
Delete packages folder from your solution directory, to remove downloaded nuget packages.
Now you should have a source only solution folder.
Now archive the full solution folder and you are good to go.

Include created folders In Project

I am working in an application that grapes real time data and stores them inside my project directory as excel sheets inside folders. My output folders are stored under bin\Debug. I click on show All to be able to see them. Is there a way to include these output folders programmatically?
Do you mean including the files in the project ? If so, you can do it by editing the project file. Project file (.csproj) is just a plain text file. First add a file and see how it affects the csproj file. After that you can programatically edit the csproj file to include the files you want.

Generate c# projects in code at runtime

I am developing a development C# Generator and I need to make a class, but I don't understand how I can make the .csproj files.
These are just text files.
cs proj is an msbuild file. And cs file is just a nomale code file.
The best thing to do is to use a sample .csproj and .cs file and use search and replace to put the correct values into it. This will get you started.
When you understand the theory you can move on to a better templating engine such as RAZOR or T4. And then onto the better techniques of generating assemblies at run time.
Create an empty solution and save it in a location. Then add a project to that solution and save the solution to a different place. Open these two solutions with a text editor and compare the files, so you can see how does the solution file change if you add a project to a solution. In the same way, if you want to add a project to that solution programatically just read the solution file using textreader edit the solution file text and write it back to the same solution file.
Hope it helps.
Try the following batch code, which requires the dotnet command to be available.
This generates your .cs program, .csproj file, bin folder and obj folder.
cd Projects
set /p user_in=Enter the new folder name:
dotnet new console -o "%user_in%"
cd "%user_in%"
dotnet restore

Setup Project and script folder moving

I include a javascript include folder in the root directory of my setup project in the Application Folder. I tried to move the javascript include file under the Javascript folder and I now get:
Unable to find source file 'C:\Documents and Settings\support\My
Documents\Projects\u2server\wwwroot\ckeditor\ckeditor_basic_source.js'
for file 'ckeditor_basic_source.js', located in
'[TARGETDIR]\wwwroot\Scripts\ckeditor', the file may be absent or
locked.
I can delete the the directory and then add the files one by one but their are over 200 files in that include directory. Is their an easy way to move a folder in the application folder of the file system view of a setup program?
When moving files on disk you also need to update your setup project. The simplest approach is to remove the entire folder in your setup project File System Editor and add it again in the correct location. This way it will use the correct paths.

How to send source code - very common question

I wanted to know what part of the project I need to copy for my USB for example in order to get the source code of the project. Do I need to copy the whole folder? Or do I need only the .sln file? Or..?because I've tried to copy the .sln file and when I try to open it with the other computer, it says that it can't open it for some reason.
Thanks in advance.
You need the whole folder. Also, if you have third party references, you'll need those assemblies as well.
You need to copy the entire folder. The source code of a c# visual studio project is the .sln, .csproj, .cs, etc and also the external dependencies, dll:s, etc.
If you view the .sln file in a text editor you can see the references it has. The open up the project files (.csproj) listed in the .sln and see the files they reference.
You have to copy each file because there are many dependencies, like forms, windows, etc.
You need whole folder..
If you just need the source code, you could copy the whole folder. If you're looking for the code, look for the C# (.cs) files within the folder, and open them with notepad++ or something later on.
If you want the project, just copy the whole project folder over.

Categories

Resources