Nuget pack ignoring my content and lib folder - nuget-package

I'm trying to create a nuget package by using the convention as described here
I think my csproj's output folder looks correct:
[projectPath]/bin/Debug/
- myProject.dll
/build
- myProject.props
/content
- myRuleset.ruleset
- CustomDictionary.xml
The spec file is the default generated spec file with the redundant nodes removed (like update info etc)
I run nuget pack -build after which the following content is packed in a nupkg file (left out _rels and package as they aren't relevant to the problem):
myProject.1.0.1.0.nupkg
/content
/build
- myProject.props
/lib
- myProject.dll
Why is my build folder inside my content folder?
Where have my content folder's files gone to?

The default generated spec file just gives you a starting point. User need to modify the spec file for nuget pack to work correctly with your project structure.
Please refer to this link http://docs.nuget.org/docs/reference/nuspec-reference, for how to include files to the package.
There is a section named "Specifying Files to Include in the Package" should give more insights.

Related

.Net core bower_components folder missing in wwwroot directory

I have fresh .Net core web app and it's source code uploaded first time on production server with CICD of the same. It went successfully but when I run the web app, the UI and js files were missing. After much digging in, I found that bower_component folder is missing which includes necessary css and js files from wwwroot folder.
Can anybody tell me why it is not uploading bower_components to the wwwroot folder?
You need to modify your .csproj file to include bower_component folder.
You can read offical document first(Include files at publish time), then you can refer below posts.
Related posts(include files, not folder) can refer to:
1. Unable to find files located in my root project folder when hosted on Azure
2. .NET Core include folder in publish
3. How to copy a folder to output directory and keep its root folder? #2949
4. dotnet core publish: include/exclude dir in output

How can I import a .props file that gets generated by a Target?

Background
I am attempting to build a C++ Visual Studio project. My project is Importing an MSBuild .targets file that specifies a single Target, "SetupConanDependencies". This Target uses the conan tool to install dependencies for a project based on a "conanfile.txt" file located in the project root directory.
The output of this Target consists of several files, including a "conanbuildinfo.props" property file. I can Import the generated .props file in my project in order to tell it how to resolve dependencies that have been installed via conan.
Here is a stripped down version of my Target definition (I have tested and verified that it does produce a "conanbuildinfo.props" file):
<Target Name="SetupConanDependencies"
Inputs="$(SolutionDir)conanfile.txt"
Outputs="$(OutDir).conan/conanbuildinfo.props"
BeforeTargets="ClCompile">
<Message Importance="High" Text="Installing project dependencies with conan..." />
<Exec Command="conan install $(ProjectDir)conanfile.txt --install-folder=$(OutDir).conan"/>
</Target>
For my question, the only relevant information is that I have a Target that is generating a .props property file. I would like to Import the generated property file in my project before building. However, I also want the Target to run automatically as part of the build process.
Question
I cannot simply Import the generated .props file inside the .targets file, because it has not yet been built by the Target.
<Import Project="$(OutDir).conan/conanbuildinfo.props"/>
<!-- Adding this line after my Target definition results in the following error, because
the file doesn't exist on disk at the time the .targets file is imported. -->
<!-- Error MSB4019 The imported project "D:\CustomBuildToolExample\Debug\.conan\conanbuildinfo.props" was not
found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. -->
Furthermore, from my current understanding of MSBuild, .props files are supposed to be Imported before .targets files. This seems to imply that I cannot Import the .props file that gets created by my Target at all, because by the time the Target generates the .props file, the project has already imported all of the Properties it will use as part of the build process.
Is there a way to include a .props file that is generated by a Target, so that my project will use the properties defined in that .props file as part of its build process?

which files/folders to exclude from source control

Im setting up a unit test project and using SVN for source control. There are two nuget packages used. Im not sure if I need to exclude the files being generated or not.
MSTest.TestAdapter.1.2.0 and MSTest.TestFramework.1.2.0
When I go to commit the files within my branch, I see a lot of what look like new files being added in this folder MSTest.TestAdapter.1.2.0/build. eg.
MSTest.TestAdapter.1.2.0/build
MSTest.TestAdapter.1.2.0/build/_common/Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
Can I exclude everything from build/* ?
As a rule of thumb, you shouldn't keep Nuget packages in svn. In Visual Studio 2017 they are not event located in your project folder structure, but in %HOME%\.nuget\packages. Reference: Should we include Nuget PACKAGE folder in version control?
I would add whole packages folder to ignored if I were you.

How can I check `bin/` directories under `node_modules/` into TFS?

I have a Team Foundation Build server behind a firewall, and I would like to check in a node_modules/ directory (powering both a Browserify client app and Node server app) associated with a project so that all of the files and dependencies needed to deploy a build are available without fetching anything.
Checking node_modules/ in to TFS seemed to work at first, except that the bin/ directories appearing in around 20 of my NPM dependencies were not checked in. bin/ does not appear in my .tfignore (or anywhere else I know of that could be preventing the check in).
These bin/ directories don't appear in the included/excluded changes in Team Explorer, at all. It's possible to locate one of these folders in Windows Explorer and add it with the TFS context menu, but doing that for all of the dependencies would be horrifically tedious and error prone.
How can I persuade TFS to detect changes in these folders? Is there some other configuration affecting included/excluded changes that I'm not aware of?
It is not recommended to upload "bin" folder or "node_modules" folder into Version Control. But if you do want to do this, following the steps below:
Go to "C:\Users\youraccount\AppData\Local\Microsoft\Team Foundation\x.0\Configuration\VersionControl" folder and open "LocalItemExclusions.config" file. (There may several folders named like 1.0, 2.0, 3.0, you need to make sure open the folder your VS current use.)
Delete the lines like following and save the file:
<Exclusion>bin</Exclusion>
<Exclusion>*.dll</Exclusion>
Close Visual Studio.
Delete "node_modules" folder.
Restart Visual Studio.
Run "npm install" command to reinstall the node modules.
Check "Pending Changes", files in "bin" folder should be listed in "Excluded Changes" section.
To check if the files and bin folders will get ignored by TFS. You could try to manually add them (such as drag to source control explorer). If you couldn't, then must related to some .tfignore settings , you may double check this such as if there is a .tfignore file in the root of the project folder level.
If you could, there maybe something wrong with your workspace or source control mapping of the bin folder. Try to remove the source control bindings and rebinding to TFS. Also give a try with delete the old workspace and use a new workspace.
You shouldn't check in node_modules - ever.
Rather use browserify or WebPack (I'd recommend WebPack) to package up your bundle.js.
Add the bundle.js to your source/scripts folder. Reference your bundle.js from your html instead of any <../node_modules/../scripts>.
Remove the npm install from your build script. you won't need it now due to referencing your bundle.js
WebPack is a dev-step, but it secures the version of packages you used during development and also saves you the npm install headache during deployment.

copy static files to build output folder in gradle

I was using ANT before (Android Project) and i had "static" files in the same packages as my code
Here is an example
src/com/my/app/test/Parser.java
src/com/my/app/test/json_to_parse.json
When executing the unit tests, the json file was copied into the gen folder, therfor it was possible to access the json in the test with
getClass().getResourceAsStream(fileName)
I had to convert the project to gradle, but now the tests are failing.
After checking the "build" folder, i've realised, the .json files are not there, therefor the getResourceAsStream method returns null.
Any idea how to include these "static" files (json, xml, ...) into the build folder?
Moving the files into the resources folder did not work out of the box in Android Studio (even though is should have)
This should be fixed in Android Studio 1.2.
However, this is what i did:
Moved all static files into the resources folder.
In my unit-test module i've added this to the build.gradle file
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources
Now, all files located inside src/test/resources will be copied into /classes/test where i can access them with
getClass().getResourceAsStream(fileName)
If i keep the package structure inside the resources folder the same as it was in the java folder, i don't need to adjust any code.
To complete the story a bit more:
JUnit4 runner requires
getClass().getResourceAsStream(name)
while Robolectric requires
getClass().getClassLoader().getResourceAsStream(name)
The files you are asking about are called "resource files" in Maven/Gradle lingo.
Gradle assumes that you are using the Maven Standard Directory Layout.
So, either you move your files into src/test/resources (then Gradle will pick them up automatically), or you tell Gradle that it should look for resources in some other place.
In the latter case, you need to modify the processTestResources task. However, keeping resource files in the same directory as source code is a bad practice. So I advise the former option.
if your problem is happen when you create apk with AndroidStudio.
you can create a jar file that includes your resources with jar.exe
for example i put a.txt into resources directory
and run this code in cmd:
"C:\Program Files\Java\jdk1.7.0_79\bin\jar" cvfe res.jar -c resources
after that a jar file "res.jar" was created
then add that res.jar into libs folder in your project
when your apk is creating resources are added to your final apk and you can use this code to acsess a.txt:
someclass.class.getClassLoader().getResourceAsStream("resources/a.txt");
with this job no need to change Gradle setting.

Resources