Some dll from nuget packages are not copied to /bin - visual-studio-2012

I know that this is a question that has been discussed before but I have a situation that I don't understand.
I have the following projects
Project A
Project B
NuGet Package "log4net"
NuGet Package "ServerAppFabric.Client"
Project A has a visual studio reference to Project B. I'm using both packages in code in Project B and I am building in debug mode. Project B config looks like this.
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Client">
<HintPath>..\packages\ServerAppFabric.Client.1.1.2106\lib\Microsoft.ApplicationServer.Caching.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Core">
<HintPath>..\packages\ServerAppFabric.Client.1.1.2106\lib\Microsoft.ApplicationServer.Caching.Core.dll</HintPath>
</Reference>
*Why is only the dll-file from log4net copied into the bin folder of Project A and not the Client and Core files? Any help or explanation is appreciated! *

I had the same problem with a somehow complex dependency graph.
Go to the Reference Properties and set Copy Local=True.
Compile and check if the assembly was copied to the bin folder.
If that doesn’t fix your issue try this answer: https://stackoverflow.com/a/19889803/1074245

In order to answer your question precisely, we'd need to know a couple of things.
One explanation depends on what references you have in Project A. For example, it could be that project A, other than referencing project B, also includes additional references, among which there are Microsoft.ApplicationServer.Caching.Client and Microsoft.ApplicationServer.Caching.Core, maybe with the option Copy local set to false - but not log4net. In this case, the copy of the former two will happen only for Project B.
Another possible explanation depends on what your code does with the references in project A and project B. The MSBuild process does not automatically copy assemblies of references that are not actually used in a project.
Finally, in case you are relying on Build Events to copy references, have a look at the Output panel to make sure that there are no errors despite a successful compilation.
In any case, in order to make sure that all NuGet packages are copied, I find it useful to edit the .csproj file and, among the <PropertyGroup> tag, add this:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
From the documentation:
If you set this CopyLocalLockFileAssemblies to true, any NuGet package dependencies are copied to the output directory. That means you can use the output of dotnet build to run your plugin on any machine.

I don't think this is related to NuGet. It should be related to how references work in Visual Studio or MSBuild. If you just reference a library in ProjectB, it won't show up in ProjectA's bin folder. However, when you use some type from the referenced library,only then it will show up in bin folder.

Related

Nuget .targets AfterTargets="Build"

I am building and using a Nuget package, and the .targets file specifies a Target like this:
<Target Name="CopyOutputFiles" AfterTargets="Build">
I didn't originally create the project, so I assume that AfterTargets="Build" is a default setting, but I'm not sure.
With this setting, the Target ends up executing right after the PostBuild step when I am consuming the package in a project in another solution.
I would like the Target to execute prior to the Post-Build step, and I found that setting the target to AfterTargets="CustomBuildStep" did what I wanted when only compiling the project in the solution that consumes the package.
<Target Name="CopyOutputFiles" AfterTargets="CustomBuildStep">
There are multiple projects in the solution that uses the package, and I'm wondering if it is harmless to change the AfterTargets= value. I'm concerned that this appears to be working when I only build one of the projects in the solution, and that it will cause unexpected problems if I clean and build all, or build the projects randomly. (because I don't fully understand the build sequence, especially when there are multiple interdependent projects in the solution.)
My question is:
Will changing the AfterTargets value from "Build" to "CustomBuildStep" cause problems when multiple projects are building within the solution, or will the behavior be predictable, as though I am only building the project that consumes the package? (i.e. will the Target always execute after the post-build step in the correct project.)

When compile the CLIPS integration source code,the CLIPSStatic in the CLIPS Solution is failed

I have checked the updated code from the weibsite: http://sourceforge.net/projects/clipsrules/
When I build the CLPSStactic project, there is an error displayed in the output window:
..\clipscpplib.cpp(281):error C2664:
"EnvAddRouterWithContext": cannot convert parameter 4 from "int (__cdecl *)(void *,const char *) to "int (__cdecl *)()""
Notes:
I use the VS2012 version
Using VS2012 open the CLIPS.sln(in the folder named "Installer")
has errors in updating to vs2012(CLIPS.vdproj, CLIPSSource.vdproj). But the CLIPS's source code has generated in the folder ../Source/CLIPS.
CLIPSDynamic and CLIPSWrapper can be compiled without errors.
I want to know why this error come out, is it related to the VS version or anything else? How to solve this?
Thank you!
#Gary Riley
If you have time, please take a look at this. Thank you!
You're using the wrong projects/solutions. Download the latest commit (r281). The solution folders in the microsoft_windows directory that you want to use are CLIPS_MVC_2010, CLIPS_MVC_2013, Examples_MVC_2010, and Examples_MVC_2013. Since you're using Visual Studio 2012, you'll probably want to use the 2010 directories. The instructions in the Advanced Programming Guide specifically reference these directories. Don't use anything in the Installer directory. You'll need to copy the CLIPS source code files from the core directory to the microsoft_windows/Source/CLIPS directory since these aren't replicated in the repository.
I have solved this problem by myself. There's the details:
Copy the "router.h" and "router.c" files from the folder "core" (http://sourceforge.net/p/clipsrules/code/HEAD/tree/)
to the folder "microsoft_windows/Source/CLIPS", and delete both origin files in the folder "../CLIPS".
Don't copy all the files in the folder "core" to "CLIPS". it won't make the CLIPSStatic project built successful either. It seems there are problems in "aggenda.h" or "aggenda.c" of the folder "core".
I think the problem is that the "router.h" and "router.c" generated by the project CLIPS in the folder named "Installer" isn't the newest version.
If you have check the code from the same website, and used the same version VS. you may encounter this problem too. And this manner can help you to solve the problem.

CMake - set_property could not find TARGET xxx. Perhaps it has not yet been created

Greetings, what I'm trying to do is to port an existing Windows application to Linux using CMake with CMakeLists, which I generated with the vcproj2cmake Script (https://github.com/sixman9/vcproj2cmake).
With the CMakeLists.txt and CMake I was able to successfully port a VS 2005 project to VS 2010. Now I try to port the same VS 2005 project to Linux, so that I can edit it with KDevelope.
The project itself is small and I think it would be easier to just create a new project and copy all relevant files (if that would work), the problem is, that it's not only one project but many, hence I was looking for a way to port a project in an as simple as possible way.
In Linux I was able to create a CMakeLists.txt using the vcproj2cmake script. The next step would be creating a KDevelope project using CMake. And this is where I'm stuck.
Everytime I try to run CMake I get the following error:
CMake Error at CMakeLists.txt: 196 (set_property) :
set_property could not find TARGET Test_Project. Perhaps it has not yet been
created.
Test_Project: installing /root/Desktop/Test_Project/vs8/CMakeLists. txt rebuilder (watching /root/Desktop/Test_Project/vs8/Test_Project. vcproj)
Configuring incomplete, errors occurred!
See also “/root/Desktop/Test_Project/vs8/CMakeFiles/CMakeOutput.log”.
I searched for a solution or an approach for quite a time now, but the only results that I get are project-specific, or at least I think they are.
Content of the CMakeLists.txt from line 196:
set_property(TARGET Test_Project PROPERTY PROJECT_LABEL "Test_Project")
v2c_rebuild_on_update(Test_Project "${CMAKE_CURRENT_SOURCE_DIR}/Test_Project.vcproj" ${CMAKE_CURRENT_LIST_FILE} "vcproj2cmake.rb" ".")
include(${V2C_HOOK_POST} OPTIONAL)
Perhaps there are more efficient ways to port many projects form Windows to Linux, I'm open for any suggestion.
It is a bit difficult to help without having your project - since you are using a third party tool to convert a VC project you should ask the author of that tool. :D
If you have many projects which you are going to maintain, I suggest that you select one where you can create a cross platform (Windows/Linux) CMake config for which you can reuse for other projects.
Most of the config should be the same for all platforms you are building for - the difference should be which generator is used and what libraries to link in the final executable (if you are building one that is). The generator is specified when running cmake.
In my opinion you should try an out of source build with the following structure:
/$COMMON_DIR/CMakeLists.txt
/CMakeLists.txt
/src/
/build/
/build/vcX
/build/generate_vcX.bat
/build/linux
/build/generate_linux.sh
$COMMON_DIR should contain the CMake code you expect to be common for all you projects - like a function to create a static library for a module which searches for files in /src and another function which can be used to add an executable for certain platform.
The CMakeLists.txt in the root of your project (repository, I assume) should call the functions defined in $COMMON_DIR and possibly add some project specific defines or link flags.

Customizing the specific output files for various Typescript input files

I've got a web project using TypeScript that has some reasonably complex requirements for the compiled output files. So for instance, I need all the *.ts files in one directory to compile down to one single .js file, and all the *.ts files in another directory to compile down to a different .js file. (It's more complex than that, but you get the idea.)
I've been able to get this working using the tsc.exe command-line, using input files and what-not, but I'd like to be able to use MSBuild .targets files - among other things, using tsc.exe from the command-line seems to be pretty poorly supported on continuous integration servers, where it can be located who-knows-where, and certainly isn't likely to be in the path.
According to this answer here, it seems like I should be able to do this using custom build targets. So I've created a custom version of Microsoft.TypeScript.targets, and in addition to the default "CompileTypeScript" target, I've created a second one, "PayboardApiV10", so that the relevant part looks like so:
<Target Name="CompileTypeScript" Condition="'$(BuildingProject)' != 'false'">
<Message Text="Compiling TypeScript files normally" Importance="high"/>
<VsTsc
ToolPath="$(TscToolPath)"
ToolExe="$(TscToolExe)"
Configurations="$(TypeScriptBuildConfigurations)"
FullPathsToFiles="#(TypeScriptCompile)"
YieldDuringToolExecution="$(TscYieldDuringToolExecution)"
OutFile="$(TypeScriptOutFile)"
OutDir="$(TypeScriptOutDir)"
>
<Output TaskParameter="GeneratedJavascript" ItemName="GeneratedJavascript" />
</VsTsc>
</Target>
<Target Name="PayboardApiV10" Condition="'$(BuildingProject)' != 'false'">
<Message Text="Compiling TypeScript files for Payboard API v1.0" Importance="high" />
<VsTsc
ToolPath="$(TscToolPath)"
ToolExe="$(TscToolExe)"
Configurations="$(TypeScriptBuildConfigurations)"
FullPathsToFiles="#(TypeScriptCompile)"
YieldDuringToolExecution="$(TscYieldDuringToolExecution)"
OutFile="Payboard.js"
OutDir="$(ProjectDir)api\v1.0\"
>
<Output TaskParameter="GeneratedJavascript" ItemName="GeneratedJavascript" />
</VsTsc>
</Target>
And then I've specified a "CustomTool" in my project configuration for the specific files that I'd like to get picked up by the "PayboardApiV10" build target, like so:
I should note that I have no idea if I'm doing this bit correctly. I can't seem to find any documentation on it, and the only examples I've been able to find are from that previous answer. And more to the point, when I run my builds, all the TS files in my project get caught up in the first build target, including the ones for which I've specified "MSBuild:PayboardApiV10" for the custom tool. The "PayboardApiV10" tool never seems to get run, i.e., I never see the message "Compiling TypeScript files for Payboard API v1.0".
So two questions:
(1) Is there a better way to do what I'm trying to do?
(2) If this is generally the right way to do it, any ideas as to what I'm doing wrong?
The direction you're going is the optimal way (on save). In the meantime you can use post-build events to transform the typescript. Right click on your project and select properties. Select Build Events and in the Post-Build area you can specify command line parameters to use tsc.exe.
On the direction you're going (compile on save) I think the project file may be missing the following on each file you want compiled:
<TypeScriptCompile Include="app.ts" />
The configuration is also likely missing the environment settings.
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
</PropertyGroup>
More information on both methods is available at this TypeScript wiki page.
I ended up asking this same question over on the TypeScript forums (https://typescript.codeplex.com/discussions/455781). The conclusions I drew from the conversation there:
There isn't a great way to do it now.
The best hacky way to do it now is probably the way that I was doing it, namely, with batch files, post-build events, and checking the compiled files into source. Other folks recommended Grunt, or the ASP.NET MVC bundling mechanism (the latter won't work in my scenario); I've also used the r.js minifier in the past. And these will work; but to reiterate, none of these are really very good solutions.
The best way to do it in the future will be to create "library projects" of TypeScript files, so that all TS files in a given project get compiled together; and then you can reference the library TS projects from your main Web project, and will automatically get the compiled files merged into your main ~/Scripts folder. But that will require support from the TS team - which Jon Turner basically indicated would be coming, though he didn't say when. (See also https://typescript.codeplex.com/workitem/571.)

Cruise Control .NET ignoring project dependencies

I have been using CC.Net successfully for some time, but now I have a problem. I added new solution to CC. It is compiled fine in VS2008, but fails in CC. The main reason is - projects in solution are built in wrong order, with no regard to dependencies. CC just tries to build them in the same order as they are stored on disc (alphabetical order).
For example, in solution there is proect Proj1 and Proj2, Proj1 has reference to Proj2. On CCNET Proj1 is built before Proj2 and throws error "CSC : error CS0006: Metadata file 'D:\xxx\Proj2\bin\Debug\Proj2.dll' could not be found".
I know this could happen when devenv is used to build solutions, but I use MSBuild.
The following code is responsible for building:
<exec>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<baseDirectory>code\src</baseDirectory>
<buildArgs>/p:Configuration=Debug /t:Rebuild PM.sln</buildArgs>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
</exec>
What am I doing wrong?
The error Metadata file could not be found:
When it happened to me, it was because there was a file called proj1.exe at that location that should not have been there. So when it used proj1.exe as the reference (instead of a proj1.dll), proj1.exe's reference to a local System.EnterpriseServices.dll failed. This was happening to me with proj1.exe referencing System.EnterpriseServices.dll which referenced System.EnterpriseServices.Wrapper.dll. Where proj1.exe was not supposed to be included in the build but someone had named a unit test app project against our team conventions.
So I recommend checking the references in the project files(unload project and edit project in vs2010 or open each project file with a text or xml editor) to make sure they are ProjectReference not Reference. Also try doing the build with /v:d in the buildArgs list so you get a more detailed build log that will show you where files were resolved to and in what order. Aa different reference that is 'successfully' resolved could be attempting to load x.dll that directly locally references your D:\xxx\Proj2\bin\Debug\Proj2.dll but fails.

Resources